mysql5.5的JDBC驱动,连接JAVA的。。麻烦哪位给发一个ppaiu-know@163.com

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql5.5的JDBC驱动,连接JAVA的。。麻烦哪位给发一个ppaiu-know@163.com相关的知识,希望对你有一定的参考价值。

http://mysql.ntu.edu.tw/Downloads/Connector-J/mysql-connector-java-5.0.8.zip

去下吧
参考技术A 记得给我分啊 发送过去了 参考技术B 发了 ,子期

无法载入com.mysql.jdbc.Driver驱动程序! 无法连接数据库!

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1352)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:127)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:65)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.jsp.testjdbc_jsp._jspService(org.apache.jsp.testjdbc_jsp:54)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)

我用的是mysql-connector-java-5.0.5-bin.jar
各种路径我都设置过了,但是还有老是出错,都奔溃了。两天了,这个问题还是没办法解决,请各位帮忙

驱动没有放对.
在%JAVA_HOME%\目录下建立mysqlforjdbc子目录,进入该目录将mysql-connector-java-3.1.10-bin.jar到该目录下

在%JAVA_HOME%\lib目录,将mysql-connector-java-3.1.10-bin-g.jar拷贝到该目录下

然后配置classpath,追加%JAVA_HOME%\lib\mysql-connector-java-5.0.5-bin.jar ;%JAVA_HOME%\mysqlforjdbc\mysql-connector-java-5.0.5-bin.jar ;

另外,server/all/lib,如果你用的不是all,在server/default/lib中也放一份试试

参考资料:http://bbs.mysql.cn/thread-1235-1-1.html

参考技术A 随便一本jsp的书,都有简单介绍与MYSQL的连接的.
以下是jsp连接数据库的例子.
<%@ page language="java" contentType="text/html; charset=GB2312" pageEncoding="GB2312"%>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<title>创建数据库</title>
</head>
<body ><font size=2>
<%
//连接需要的对象
Connection conn = null;
Statement stmt = null;
String sql = null;
ResultSet rs = null;
int ret;
try
/*请确认已经安装mysql服务器,并且用户名root,密码为root*/
Class.forName("com.mysql.jdbc.Driver"); //载入JDBC驱动程序
String strCon = "jdbc:mysql://localhost:3306/"; //连接字
conn = DriverManager.getConnection(strCon,"root","root"); //连接数据库
stmt = conn.createStatement(); //初始化查询
sql = "create database JspSamples"; //创建数据库
ret = stmt.executeUpdate(sql); //执行创建数据库
sql = "use JspSamples"; //选择数据库
ret = stmt.executeUpdate(sql); //执行选择数据库
sql = " CREATE TABLE customers(" + //创建表
" Id int(6) unsigned NOT NULL auto_increment," +
" Name varchar(20) default NULL," +
" addTime timestamp NULL default NULL," +
" Tel varchar(15) default NULL," +
" Email varchar(20) default NULL," +
" PRIMARY KEY (Id)" +
" )";
ret = stmt.executeUpdate(sql); //执行创建表


catch(ClassNotFoundException e) //意外处理,驱动程序无法找到
e.printStackTrace();
out.println("<h1>无法找到数据库驱动</h1>");

catch(SQLException e1) //意外处理,数据库操作失败
e1.printStackTrace();
out.println("<h1>数据库操作失败</h1>");


out.println("<h1>新建数据库JspSamples成功</h1>");
DatabaseMetaData meta = conn.getMetaData(); //获取数据库信息
out.println("<br>");
out.println("连接字:" + meta.getURL()); //获取连接字
out.println("<br>");
out.println("数据库产品:" + meta.getDatabaseProductName()); //获取数据库产品名
out.println("<br>");
out.println("数据库版本:" + meta.getDatabaseProductVersion() ); //获取数据库产品版本
out.println("<br>");
out.println("驱动程序:" + meta.getDriverName() ); //获取数据库驱动名
out.println("<br>");
out.println("驱动程序版本:" + meta.getDriverVersion() ); //获取数据库驱动版本

stmt.close(); //关闭查询
conn.close(); //关闭连接
%>
</font>
</body>
</html>

以上是关于mysql5.5的JDBC驱动,连接JAVA的。。麻烦哪位给发一个ppaiu-know@163.com的主要内容,如果未能解决你的问题,请参考以下文章

JDBC总结篇

Mysql-connector-java驱动版本问题

C3P0 mysql 5.7

MySQL5.5.21图解教程

Win7系统安装MySQL5.5.21图解教程

MyCAT 连接MySQL 8 注意事项