com.mysql.jdbc.Driver 问题

com.mysql.jdbc.Driver 为啥没有实现java.sql.Driver#getParentLogger()方法但是编译确不报错,有点费解~
求大神指点迷津~

5个回答

基类实现了,继承的派生类不需要再次实现。

看一下API你就知道有没有实现了

可以用Eclipse创建一个Driver类的对象,然后试试调用是否有这个方法呗

java.sql.Driver driver = new com.mysql.jdbc.Driver();

注意看,你现在持有的对象是mysql的对象,但是你的引用却是java.sql.Driver,
编译时编译器会查看引用是否有getParentLogger()这个方法,对于编译器来说它认为当前对象就是java.sql.Driver所以不报错。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
java.lang.ClassNotFoundException: com.mysql.jdbc.driver的问题
[color=#FF0000]propStream = SqlHelper.class.getClassLoader()rn .getResourceAsStream("dbinfo.properties prop.load(propStream);rnrn driver = prop.getProperty("driver");rn url = prop.getProperty("url");rn username = prop.getProperty("username");rn password = prop.getProperty("password");rnrn Class.forName("com.mysql.jdbc.driver");");[/color]rnrn自从添加了propStream = SqlHelper.class.getClassLoader()rn .getResourceAsStream("dbinfo.properties");后就发生rn[color=#FF0000]java.lang.ClassNotFoundException: com.mysql.jdbc.driverrn at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1438)rn at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1284)rn at java.lang.Class.forName0(Native Method)rn at java.lang.Class.forName(Unknown Source)rn at com.skybird.util.SqlHelper.(SqlHelper.java:47)rn at com.skybird.model.UserService.checkUser(UserService.java:25)rn at com.skybird.controller.LoginVerify.doPost(LoginVerify.java:47)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:881)rn at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:674)rn at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:541)rn at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(Unknown Source)[/color]rn错误,但是在tomcat bin目录下已经有mysql的连接驱动,并且查询数据库可以正常使用,只是报有这个错误,怀疑是SqlHelper.class.getClassLoader()加载的问题,请各位给看看神马原因?????
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver问题
今天学到Jdbc了,看那个传智播客的视频教程,我下了mysql,驱动也下了。。包也导到项目里了。。可是有下面异常rn[code=Java]java.lang.ClassNotFoundException: com.mysql.jdbc.Driverrn at java.net.URLClassLoader$1.run(Unknown Source)rn at java.security.AccessController.doPrivileged(Native Method)rn at java.net.URLClassLoader.findClass(Unknown Source)rn at java.lang.ClassLoader.loadClass(Unknown Source)rn at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)rn at java.lang.ClassLoader.loadClass(Unknown Source)rn at java.lang.ClassLoader.loadClassInternal(Unknown Source)rn at java.lang.Class.forName0(Native Method)rn at java.lang.Class.forName(Unknown Source)rn at jdbctest.Base.test(Base.java:25)rn at jdbctest.Base.main(Base.java:13)rn[/code]rn我上网查了一下资料,还是没成功,大家说说可能的原因吧。我一个一个试,在线等,谢谢了。。。
SSH框架com.MySQL.jdbc.Driver问题
大神们,我从辅导班出来一直没找到工作,自己在家跟项目,结果架包方向就出现问题,希望大家能帮我解决一下,不胜感激!rn如果需要其他信息可以说下,我回帖上去。rn错误报告如下:rnjava.lang.ClassNotFoundException: com.MySQL.jdbc.Driverrn at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)rn at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)rn at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)rn at java.lang.Class.forName0(Native Method)rn at java.lang.Class.forName(Class.java:169)rn at com.mchange.v2.c3p0.DriverManagerDataSource.ensureDriverLoaded(DriverManagerDataSource.java:101)rn at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:133)rn at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)rn at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)rn at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)rn at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)rnapplecationContext.xml相关配置如下:rn rn rn rn rn rn rn rn rn rnrnjdbc.properties如下:rnjdbc.driver = com.MySQL.jdbc.Driverrnjdbc.url = jdbc:mysql://localhost:3306/MySQLrnjdbc.user = rootrnjdbc.password =rootrnrnrn[img=https://img-bbs.csdn.net/upload/201704/09/1491742224_139175.png][/img][img=https://img-bbs.csdn.net/upload/201704/09/1491742263_990853.png][/img][img=https://img-bbs.csdn.net/upload/201704/09/1491742272_886047.png][/img][img=https://img-bbs.csdn.net/upload/201704/09/1491742284_123953.png][/img]
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
写了一个很简单的Java连接数据库的程序rnrn运行环境是Linux(服务器),编写代码环境是windowsrnrn现在的问题是,放到服务器Linux上,javac hello.java生成hello.class可以正常运行rn但是如果在windows上使用Eclipse导出成jar包(用Eclipse插件fatjar导出的),都会产生如下错误:java.lang.ClassNotFoundException: com.mysql.jdbc.Driverrnrn由于最后需要解决的是一个比较大的项目,所以最好能导成jar包运行,所以希望得到解决方式,本人是Java新手rnrnrnimport java.sql.*;rnrnpublic class hellornrn public static void main(String[] args)rn rn String driver = "com.mysql.jdbc.Driver"; //driver¡ªjar included in CLASSPATHrn String url = "jdbc:mysql://localhost/dns"; //connector, test is DB name.rn String user = "root"; // user namern String password = ""; //user passwordrn ResultSet rs;rn String domain;rnrnrn try rn Class.forName(driver);rn Connection conn = DriverManager.getConnection(url, user, password);rn if(!conn.isClosed())rn System.out.println("Succeeded connecting to the Database!");rn Statement statement;rn statement = conn.createStatement();rnrn String sql = "select * from fast;";rnrn rs = statement.executeQuery(sql);rn if(rs.next()) rn domain = rs.getString("name");rn System.out.print(domain);rn rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn catch (ClassNotFoundException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rnrnrnrnrnrn rnrn
java.lang.ClassNotFoundException:com.mysql.jdbc.Driver
我的mysql驱动包已经引入到工程里了,可是还会显示java.lang.ClassNotFoundException:com.mysql.jdbc.Driver的错误,rn代码是:rnClass.forName("com.mysql.jdbc.Driver");rncon=DriverManager.getConnection("jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=GBK","root","admin");rn但是我又新建了一个javase工程,却插入数据成功了。不知道为什么?rn我用netstat -an在控制台看了一下,发现有两个3306端口,有关系吗?rn
ClassNotFoundException:com.mysql.jdbc.Driver
连接不上mysql数据库,我的驱动包是从官网下的最新版本的,java文件是在jcreator中写的,只是一个测试数据库连接的文件,我的做法是这样的:rn把下载的驱动放在C:\Java\jre6\lib目录下,这是jcreator使用的jdk,然后再classpath中加入了数据库驱动的路径,但是执行时依然提示找不到驱动!从网上找了半天,一直都没找到答案,不知道是怎么回事?rn测试数据库连接的代码如下:rnimport java.sql.*;rnpublic class Test rnpublic static Connection getConnection() throws SQLException ,rnjava.lang.ClassNotFoundExceptionrnString url = "jdbc:mysql://localhost:3306/studentinfo";rnClass.forName("com.mysql.jdbc.Driver");rnString userName = "root";rnString password = "123";rnConnection con = DriverManager.getConnection(url,userName,password);rnreturn con;rnrnpublic static void main(String[] args) rntryrnConnection con = getConnection();rnStatement sql = con.createStatement();rnsql.execute("drop table if exists student");rnsql.execute("create table student(id int not null auto_increment,name varchar(20) not null default 'name',math int not null default 60,primary key(id));");rnsql.execute("insert student values(1,'AAA','99')");rnsql.execute("insert student values(2,'BBB','77')");rnsql.execute("insert student values(3,'CCC','65')");rnString query = "select * from student";rnResultSet result = sql.executeQuery(query);rnSystem.out.println("Student 表数据如下:");rnSystem.out.println("---------------------------------");rnSystem.out.println(" 学号"+" "+"姓名"+" "+"数学成绩");rnSystem.out.println("---------------------------------");rnint number;rnString name;rnString math;rnwhile(result.next())rnnumber = result.getInt("id");rnname = result.getString("name");rnmath = result.getString("math");rnSystem.out.println(number + " " + name + " " + math);rnrnsql.close();rncon.close();rncatch(java.lang.ClassNotFoundException e)rnSystem.err.println("ClassNotFoundException:" + e.getMessage());rncatch(SQLException ex)rnSystem.err.println("SQLException:" + ex.getMessage());rnrnrn
java.lang.ClassNotFoundException: com.mysql.jdbc.driver
我用eclipse3.1.2 想测试一下JDBC连MYSQL可不可以用代码是[code=Java]rnpublic static void main(String [] args) throws SQLException rn String driver="com.mysql.jdbc.driver";rn String url="jdbc:MySQL://localhost:3306/mysql";rn String password="zm198635";rn String user="root";rn tryrn Class.forName(driver);rn Connection con=DriverManager.getConnection(url,user,password);rn String insert="insert ddd(ddd) value(?)";rn PreparedStatement stmt=con.prepareStatement(insert);rn int []aa=1,2,3;rn for(int i=0;i
JDBC:DriverManager.registerDriver(new com.mysql.jdbc.Driver()););
DriverManager.registerDriver(new com.mysql.jdbc.Driver());rn在java中用这种方式注册驱动,程序出错,有包rn用Class.forName("com.mysql.jdbc.Driver")这个就没有错
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver报错
导入了mysql-connector-java-5.1.20-bin.jar包到项目lib目录下,但是运行的时候,myeclipse还是报错:rnjava.lang.ClassNotFoundException: com.mysql.jdbc.Driverrn at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)rn at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)rn at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:128)rn at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)rn at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)rn at java.lang.Class.forName0(Native Method)rn at java.lang.Class.forName(Class.java:169)rn at org.apache.jsp.find_005fstu_005f1_jsp._jspService(find_005fstu_005f1_jsp.java:93)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)rn at java.lang.Thread.run(Thread.java:619)[img=https://img-bbs.csdn.net/upload/201704/24/1493011140_782070.jpg][/img]
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver求助
我上百度查过,很多都是说因为没有引进mysql—connector的那个jar包所以无法加载驱动。但是我引进了仍然有这个问题,我知道如何引进,工程右键,构建路径,配置构建路径,add external jar 选中即可。我之前用java做一个简单的人员管理系统也这样的,成功了。这一次却怎么也不成功。为什么!求助各位大神!值得一提的是我使用的eclipse是叫什么gallie的版本(不知道输错了没,差不多是这个词),之前成功的那次不是这个eclipse。这个有影响吗?
com.mysql.jdbc.Driver驱动包工具
com.mysql.jdbc.Driver驱动包
com.mysql.jdbc.Driver驱动包
mysql的jdbc驱动包,需要的可以下载
Tomcat5.0 连接池 ClassNotFoundException:com.mysql.jdbc.Driver
目前正在初学连接池 发生了个奇怪的问题 使用正常连接jdbc没有问题 但是用连接池就出现ClassNotFoundException:com.mysql.jdbc.Driver 错误rn我jar包已经放入工程的lib目录内 请朋友们帮忙rnrn我的部分原文:rnjava代码中:rntry rn rn[color=#99CC00]// Class.forName("com.mysql.jdbc.Driver"); rn// con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");[/color] rn rn InitialContext ic=new InitialContext();rn DataSource ds=(DataSource)ic.lookup("java:comp/env/jdbc/dateTest");rn rn [color=#FF6600]con=ds.getConnection();[/color]rn st=con.createStatement();rn rs=st.executeQuery("SELECT * FROM menu");rn while(rs.next())rn Item i=new Item(rs.getInt(1),rs.getString(2));rn al.add(i);rn rn catch (Exception e) rn e.printStackTrace();rn rn结果[color=#FF0000]st=con.createStatement();[/color]出错rnrn我的工程名是:dateSourcernC:\Program Files\Apache Software Foundation\Tomcat 5.0\conf\Catalina\localhost\dateSource.xml:rnrnrnrn rnrn rn rn maxWaitrn 5000rn rn rn maxActivern 10rn rn rn passwordrn rootrn rn rn urlrn jdbc:mysql://localhost:3306/testrn rn rn driverClassNamern com.mysql.jdbc.Driverrn rn rn maxIdlern 2rn rn rn usernamern rootrn rn rnrnrn工程的web.xml中:rn rn jdbc/dateTestrn javax.sql.DataSourcern Containerrn rnrn错误信息为:rnrg.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'rn at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:766)rn at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)rn at com.wish.dao.ItemDAO.getAll(ItemDAO.java:35)rn at com.wish.contorlly.ItemServlet.doGet(ItemServlet.java:30)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)rn at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)rn at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)rn at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)rn at java.lang.Thread.run(Thread.java:619)rnCaused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driverrn at org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:854)rn at org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:721)rn at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)rn at java.lang.Class.forName0(Native Method)rn at java.lang.Class.forName(Class.java:169)rn at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:760)rn ... 29 morernrn我在强调一下:工程的lib目录下有[color=#FF6600]mysql-connector-java-5.0.3-bin.jar[/color]rn而且在rnC:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\dateSource\WEB-INF\lib也有rnmysql-connector-java-5.0.3-bin.jar rnrn为什么还是ClassNotFoundException错误呢??rnrn因为是新人暂无分数 所以请各位现帮忙 谢谢了
为什么找不到com.mysql.jdbc.Driver
为什么找不到com.mysql.jdbc.Driverrnrn目录结构如下:rnrnc:\test\TestC.javarnc:\test\mysql.jar(驱动程序)rnrn编译rnjavac c:/test/TestC.java 通过rnrn执行rnjava c:/test/TestC -classpath c:/test/mysql.jarrnrn错误如下:java.lang.ClassNotFoundException: com.mysql.jdbc.Driverrnrn不要将mysql.jar加到类路径中,就使用 -classpath 这种方式手工设置,怎么做啊?rnrn多谢!rn
求解决java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
我是用mysql的rn数据库是5.1.36rnmysql> select version();、rnrn| version() |rn+----------------------+rn| 5.1.36-community-log |rn+----------------------+rnrn遇上java.lang.ClassNotFoundException: com.mysql.jdbc.Driverrn网上下载数据库驱动mysql-connector-java-5.1.36-bin,不知放哪里。我看过那些帖,都说放在lib中,哪里的lib啊?rn我快炸了,希望广大朋友能帮一下,谢谢。rnrn
运行时的异常:com.mysql.jdbc.Driver
没有错误,catch的异常为:com.mysql.jdbc.Driverrnjsp文件为:rn<%@ page language="java" %>rn<%@ page import="java.sql.*" %>rnrnrn welcomernrnrn<%String name=request.getParameter("name");%>rn<%String email=request.getParameter("email");%>rn<%tryrn Class.forName("com.mysql.jdbc.Driver");rn catch(ClassNotFoundException e)rn System.err.println("sql_data():"+e.getMessage());rn rn tryrn Connection con=DriverManager.getConnection("jdbc:mysql://localhost/mytest?user=root");rn Statement stmt=con.createStatement();rn String sql="INSERT INTO liuyan (name,email) VALUES('"+name+"','"+email+"')";rn stmt.executeUpdate(sql);rn rn rn catch(Exception e)out.println(e.getMessage());rn %>rnrnrn而连接数据库的一段写成java程序没有异常rn
有关:java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
在网上google过,在WEB工程将MySql驱动。加入到WEB-INF/LIB里头可将其搞定,可是我要问的是,这JAVA 工程又得加在哪呢。rn SRC目录? 试过不行,有大虾可以帮到的吗
eclipse 报错java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
实在解决不了了!搞了好几天了!rn操作系统:ubuntu 14.04 LTSrneclipse版本:3.8.1rnmysql版本:5.5.49 安装在本机,作为服务器,eclipse也是在本机跑的rn下载的驱动版本: mysql-connector-java-5.1.39-bin.jar放置在目录 /usr/libjvm/java-1.7.0-openjdk-amd64/jre/lib/ext/ 下rnrn代码如下:rnrnimport java.sql.Connection;rnimport java.sql.DriverManager;rnimport java.sql.ResultSet;rnimport java.sql.SQLException;rnimport java.sql.Statement;rnpublic class ShowInfo rn private static final String SQLEXCEPTION = "jdbc:mysql://127.0.0.1:3306/mydb?mytable=root&password=";rn private static final String SQL = "jdbc:mysql://127.0.0.1/mydb?";rn private static final String USER = "root";rn private static final String PASSWORD = "";rn /**rn * @param argsrn */rn public static void main(String[] args) rn // TODO Auto-generated method stubrn System.out.println("userId info:"); rn getInfoFromDatabase(SQL, USER, PASSWORD, 1); rn System.out.println("=================================="); rn System.out.println("userName info:"); rn getInfoFromDatabase(SQL, USER, PASSWORD, 2); rn rn // 报异常信息:Access denied for user ''@'localhost' to database 'mydb' rn getInfoFromDatabase(SQLEXCEPTION, 1);rn rn rn public static void getInfoFromDatabase(String sql, String user, String password, int columnIndex) rn Connection conn = null; rn Statement statement = null; rn ResultSet result = null; rn try rn //Class.forName("com.mysql.jdbc.Driver").newInstance(); rn Class.forName("com.mysql.jdbc.Driver");//加载类Driver rn conn = DriverManager.getConnection(sql, user, password); rn statement = conn.createStatement(); rn result = statement.executeQuery("select * from mytable"); rn while (result.next()) rn System.out.println("userName= " + result.getString(columnIndex)); rn rn catch (ClassNotFoundException e) rn e.printStackTrace(); rn catch (SQLException e) rn e.printStackTrace(); rn finally rn try rn if (result != null) rn result.close(); rn result = null; rn rn if (statement != null) rn statement.close(); rn statement = null; rn rn if (conn != null) rn conn.close(); rn conn = null; rn rn catch (SQLException e) rn e.printStackTrace(); rn rn rn rn rn public static void getInfoFromDatabase(String sql, int columnIndex) rn Connection conn = null; rn Statement statement = null; rn ResultSet result = null; rn try rn //Class.forName("com.mysql.jdbc.Driver").newInstance(); rn Class.forName("com.mysql.jdbc.Driver"); rn conn = DriverManager.getConnection(sql); rn statement = conn.createStatement(); rn result = statement.executeQuery("select * from mytable"); rn while (result.next()) rn System.out.println("userName= " + result.getString(columnIndex)); rn rn catch (ClassNotFoundException e) rn e.printStackTrace(); rn catch (SQLException e) rn e.printStackTrace(); rn finally rn try rn if (result != null) rn result.close(); rn result = null; rn rn if (statement != null) rn statement.close(); rn statement = null; rn rn if (conn != null) rn conn.close(); rn conn = null; rn rn catch (SQLException e) rn e.printStackTrace(); rn rn rn rnrnrnrnrn报错信息如下::::rnuserId info:rnjava.lang.ClassNotFoundException: com.mysql.jdbc.Driverrn at java.net.URLClassLoader$1.run(URLClassLoader.java:366)rn at java.net.URLClassLoader$1.run(URLClassLoader.java:355)rn at java.security.AccessController.doPrivileged(Native Method)rn at java.net.URLClassLoader.findClass(URLClassLoader.java:354)rn at java.lang.ClassLoader.loadClass(ClassLoader.java:425)rn at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)rn at java.lang.ClassLoader.loadClass(ClassLoader.java:358)rn at java.lang.Class.forName0(Native Method)rn at java.lang.Class.forName(Class.java:195)rn at zrkj.ShowInfo.getInfoFromDatabase(ShowInfo.java:34)rn at zrkj.ShowInfo.main(ShowInfo.java:19)rn==================================rnuserName info:rnjava.lang.ClassNotFoundException: com.mysql.jdbc.Driverrn at java.net.URLClassLoader$1.run(URLClassLoader.java:366)rn at java.net.URLClassLoader$1.run(URLClassLoader.java:355)rn at java.security.AccessController.doPrivileged(Native Method)rn at java.net.URLClassLoader.findClass(URLClassLoader.java:354)rn at java.lang.ClassLoader.loadClass(ClassLoader.java:425)rn at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)rn at java.lang.ClassLoader.loadClass(ClassLoader.java:358)rn at java.lang.Class.forName0(Native Method)rn at java.lang.Class.forName(Class.java:195)rn at zrkj.ShowInfo.getInfoFromDatabase(ShowInfo.java:34)rn at zrkj.ShowInfo.main(ShowInfo.java:22)rnjava.lang.ClassNotFoundException: com.mysql.jdbc.Driverrn at java.net.URLClassLoader$1.run(URLClassLoader.java:366)rn at java.net.URLClassLoader$1.run(URLClassLoader.java:355)rn at java.security.AccessController.doPrivileged(Native Method)rn at java.net.URLClassLoader.findClass(URLClassLoader.java:354)rn at java.lang.ClassLoader.loadClass(ClassLoader.java:425)rn at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)rn at java.lang.ClassLoader.loadClass(ClassLoader.java:358)rn at java.lang.Class.forName0(Native Method)rn at java.lang.Class.forName(Class.java:195)rn at zrkj.ShowInfo.getInfoFromDatabase(ShowInfo.java:71)rn at zrkj.ShowInfo.main(ShowInfo.java:25)rnrnrn加载过jdbc 的包了。。。rn[img=https://img-bbs.csdn.net/upload/201606/23/1466691617_169162.png][/img]rn
com.mysql.jdbc.driver和org.jgt.mm.mysql.driver有什么区别?
com.mysql.jdbc.driver和org.jgt.mm.mysql.driver有什么区别?
jsp javax.servlet.ServletException: com.mysql.jdbc.Driver
在tomcat里单独写一个jsp文件,启动tomcat服务后,在浏览器里面运行时,总是提示一下:rnjsp javax.servlet.ServletException: com.mysql.jdbc.Driverrn我下了一个mysql驱动mysql-connector-java-3.0.9-stable-bin.jar包,但是不知道放到哪里使页面正常运行rn望各路大侠拔刀相助!!!
关于Class.forName("com.mysql.jdbc.Driver");
如果只导入:rnimport com.mysql.jdbc.Driver;rn不DriverManager.registerDriver(new Driver());rn与rnClass.forName("com.mysql.jdbc.Driver");rn有什么区别?
请教java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
错误信息:rn---------------------------------------------------------------rnjava.lang.ClassNotFoundException: com.mysql.jdbc.Driverrnrnjsp:rn----------------------------------------------------------------rn<%@ page language="java" import="java.util.*,pack.*,java.sql.*" %>rnrnrnrnrnrnrn <%rn Connection con = GetCon.get();rn Statement stmt = con.createStatement();rn ResultSet rs = stmt.executeQuery("select count(*) from Offices");rn rs.next();rn %>rn <%=rs.getInt(1)%>rnrnrnrnrn调用的类GetCon:rn---------------------------------------------------rnpackage pack;rnrnimport java.sql.Connection;rnimport java.sql.DriverManager;rnimport java.sql.ResultSet;rnimport java.sql.SQLException;rnimport java.sql.Statement;rnrnpublic class GetCon rn public static Connection get() throws SQLException rn Connection con = null;rn try rn Class.forName("com.mysql.jdbc.Driver");rn DriverManager.registerDriver(new com.mysql.jdbc.Driver());rn String dbUrl = "jdbc:mysql://localhost:3306/report?useUnicode&characterEncoding=GB2312&user=root";rn String dbUser = "root";rn String dbPwd = "";rn rn con = java.sql.DriverManager.getConnection(dbUrl);rn catch(Exception e) rn System.out.println(e);rn rn return con;rn rn public static void main(String[] args) rn tryrn Connection con;rn Statement stmt;rn ResultSet rs;rn rn con = GetCon.get();rn stmt = con.createStatement();rn rs = stmt.executeQuery("select count(*) from ReportByMonth");rn rs.next();rn System.out.println(rs.getInt(1));rn catch (Exception e) rn System.out.println(e);rn rn rnrn
运行时异常提示:com.mysql.jdbc.Driver
jsp文件为:rn<%@ page language="java" %>rn<%@ page import="java.sql.*" %>rnrnrn welcomernrnrn<%String name=request.getParameter("name");%>rn<%String email=request.getParameter("email");%>rn<%tryrn Class.forName("com.mysql.jdbc.Driver");rn catch(ClassNotFoundException e)rn System.err.println("sql_data():"+e.getMessage());rn rn tryrn Connection con=DriverManager.getConnection("jdbc:mysql://localhost/mytest?user=root");rn Statement stmt=con.createStatement();rn String sql="INSERT INTO liuyan (name,email) VALUES('"+name+"','"+email+"')";rn stmt.executeUpdate(sql);rn rn rn catch(Exception e)out.println(e.getMessage());rn %>rnrnrn而连接数据库的一段写成java程序没有异常
Error: java.io.IOException: com.mysql.jdbc.Driver
通过QuartJob调用mapreduce,报了如下错误,求解rn[color=#FF0000]Error: java.io.IOException: com.mysql.jdbc.Driver[/color]rn at org.apache.hadoop.mapreduce.lib.db.DBOutputFormat.getRecordWriter(DBOutputFormat.java:185)rn at org.apache.hadoop.mapred.ReduceTask$NewTrackingRecordWriter.(ReduceTask.java:540)rn at org.apache.hadoop.mapred.ReduceTask.runNewReducer(ReduceTask.java:614)rn at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:389)rn at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)rn at java.security.AccessController.doPrivileged(Native Method)rn at javax.security.auth.Subject.doAs(Subject.java:422)rn at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1693)rn at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)
com.mysql.jdbc.Driver 找不到包
明明已经导入了:rn[img=https://img-bbs.csdn.net/upload/201511/22/1448150848_577014.png][/img]rnrn[code=java]<%@ page language="java" import="java.util.*" pageEncoding="utf-8" import="java.sql.*"%>rn<%rnString path = request.getContextPath();rnString basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";rn%>rnrnrnrn rn rn rn My JSP 'index.jsp' starting pagern rn rn rn rn rn rn rn rn rn <%rn try rn // 加载数据库驱动,注册到驱动管理器rn Class.forName("com.mysql.jdbc.Driver");rn // 数据库连接字符串rn String url = "jdbc:mysql://localhost:3306/test";rn // 数据库用户名rn String username = "root";rn // 数据库密码rn String password = "111";rn // 创建Connection连接rn Connection conn = DriverManager.getConnection(url,username,password);rn // 判断 数据库连接是否为空rn if(conn != null)rn // 输出连接信息rn out.println("数据库连接成功!");rn // 关闭数据库连接rn conn.close();rn elsern // 输出连接信息rn out.println("数据库连接失败!");rn rn catch (ClassNotFoundException e) rn System.out.println("找不到包!");rn catch (SQLException e) rn System.out.println("SQLException");rn rn%>rn rnrn[/code]
jsp连接MYSQL的问题,出错org.apache.jasper.JasperException: com.mysql.jdbc.Driver
我在网上下栽mysql-connector-java-3.0.9-stable-bin.jar,也把他放到CLASSPATH里面了,并且考到 jre/lib/ext下了,rn代码如下:rn<%@ page contentType="text/html;charset=gb2312"%> rn<%@ page import="java.sql.*"%> rn <%rnClass.forName("com.mysql.jdbc.Driver").newInstance();rn%>rnrn错误提示:rnrnorg.apache.jasper.JasperException: com.mysql.jdbc.Driverrn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rn at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rn at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)rn at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)rn at java.lang.Thread.run(Thread.java:536)rn
用com.mysql.jdbc.Driver连接mysql4.0.6的中文问题
问题是rnstmt.executeUpdate("INSERT INTO tableName name VALUES '中文'");rn就要出错,错误提示为sql语法错误,rn但是当values的值是英文的时候就没有问题,rn如:stmt.executeUpdate("INSERT INTO tableName name VALUES '123");rn我在dburl中也设置了也设置了字符集的参数,gb2312,gbk,iso8859-1都试验过了,都是相同问题,从数据库中取出来的中文字符也是???rn但是原来用org.gjt.mm.mysql.Driver的驱动的时候就没有出现过这种问题,当时的org.gjt.mm.mysql.Driver版本是1.*的 ,rn这是怎么回事?各位英雄rn
Cannot load JDBC driver class 'com.mysql.jdbc.driver'问题
[size=14px][color=#FF0000][b]我用的是maven 用spring mvc写项目 可是运行的时候报错,我的MySQL的驱动包的依赖添加到pom文件了啊。求各位大神帮帮忙啊[/b][/color][/size]rnCannot load JDBC driver class 'com.mysql.jdbc.driver'rnjava.lang.ClassNotFoundException: com.mysql.jdbc.driverrn at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)rn at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)rn at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)rn at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:401)rn at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:363)rn at java.lang.Class.forName0(Native Method)rn at java.lang.Class.forName(Unknown Source)rn at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1130)rn at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)rn at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)rn at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:113)rn at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2863)rn at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859)rn at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)rn at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:860)rn at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:779)rn at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)rn at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)rn at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)rn at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)rn at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:553)rn at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)rn at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)rn at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)rn at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)rn at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)rn at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)rn at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)rn at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)rn at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)rn at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:549)rn at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)rn at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)rn at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)rn at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)rn at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:115)rn at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)rn at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)rn at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)rn at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)rn at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)rn at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)rn at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)rn at org.mortbay.jetty.Server.doStart(Server.java:224)rn at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)rn at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)rn at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:454)rn at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:396)rn at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210)rn at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)rn at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)rn at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)rn at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)rn at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)rn at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)rn at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)rn at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)rn at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)rn at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)rn at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)rn at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)rn at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)rn at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)rn at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
java找不到类com.mysql.jdbc.Driver的异常
我已经把那个jar文件 mysql-connector-java-5.0.8-bin.jar 拷贝到了 CLASSPATH里rn但还是出现这个异常 为之奈何?rnrn那段jdbc源代码:rn[code=Java]rntryrn rn Connection conn;rn Statement stmt;rn ResultSet res;rn //加载Connector/J驱动rn //这一句也可写为:Class.forName("com.mysql.jdbc.Driver");rn Class.forName("com.mysql.jdbc.Driver").newInstance();rn //建立到MySQL的连接rn conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/information_schema",rn "root", "root");rn //执行SQL语句rn stmt = conn.createStatement();rn res = stmt.executeQuery("select * from pet");rn //处理结果集rn while (res.next())rn rn String name = res.getString("name");rn System.out.println(name);rn rn res.close();rn rn rn catch (Exception ex)rn rn System.out.println("Error : " + ex.toString());rn rn[/code]
myeclipse不识别Class.forName("com.mysql.jdbc.Driver")
myeclipse不识别Class.forName("com.mysql.jdbc.Driver")rnrnrn问题是有个javaweb项目用到jbdc可以使用[img=https://img-bbs.csdn.net/upload/201309/20/1379665889_775238.jpg][/img]rnrn自学很苦逼,忘大神给解决一下
Class.forName("com.mysql.jdbc.Driver");不执行,什么原因呢?
在主机上运行良好,mysql也设好了,可以外部IP访问。rn当把程序放到虚拟机里时,就不行了,加了很多语句后,发现只在“链接错误0”弹出了对话框,后面的Class.forName("com.mysql.jdbc.Driver");执行没有?为什么呢?rnrn[code=Java]rnif(ID && PASSWORD && jComboBox.getSelectedItem()=="学生")rn try rn JOptionPane.showMessageDialog(lab3, "链接错误0","提示",JOptionPane.INFORMATION_MESSAGE);rn Class.forName("com.mysql.jdbc.Driver");rn JOptionPane.showMessageDialog(lab3, "链接错误1","提示",JOptionPane.INFORMATION_MESSAGE);rn conn = DriverManager.getConnection(LoginFrame.IP,"admin", "admin");//Connectionrn JOptionPane.showMessageDialog(lab3, "链接错误2","提示",JOptionPane.INFORMATION_MESSAGE);rn stmt = conn.createStatement();//Statementrn JOptionPane.showMessageDialog(lab3, "链接错误3","提示",JOptionPane.INFORMATION_MESSAGE);rn SQL = "select * from Student where stuID='" + c_username.getText() + "' and stuPwd='"+ String.valueOf(c_password.getPassword())+"'";rn rs = stmt.executeQuery(SQL);rn JOptionPane.showMessageDialog(lab3, "链接错误4","提示",JOptionPane.INFORMATION_MESSAGE);rn boolean m = false; //判断是否帐号密码错误.false为失败.rn[/code]rnrn
Cannot load driver class: com.mysql.jdbc.Driver
rnCaused by: java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driverrn at org.springframework.util.Assert.state(Assert.java:94) ~[spring-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:224) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]rn at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:176) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]rn at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:43) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]rn at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari.dataSource(DataSourceConfiguration.java:81) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161]rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161]rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161]rn at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161]rn at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn ... 70 common frames omittedrn[img=https://img-bbs.csdn.net/upload/201804/20/1524239876_893584.png][/img]rn[img=https://img-bbs.csdn.net/upload/201804/20/1524239905_51819.png][/img]
com.mysql.jdbc.Driver驱动包,亲测可用
com.mysql.jdbc.Driver驱动包,亲测可用,自用版,
Web--项目报com.mysql.jdbc.Driver错误解决办法
Web项目一直报com.mysql.jdbc.Driver错误,给项目添加了路径也无法解决 由于是由Tomcat启动Web项目,所以Tomcat也需要可以识别Mysql的jar包 所以正确的方式分为两步:1.先给Tomcat的lib文件夹中添加一个MysqL的jar包                                                 2.再给项目添加包的路径
com.mysql.jdbc.Driver cannot be resolved to a variable
[img=https://img-bbs.csdn.net/upload/201702/10/1486702669_856611.png][/img]package com.per.util;rn[code=java]import java.sql.DriverManager;rnimport com.mysql.jdbc.JDBC4CallableStatement;rnimport com.sun.jndi.ldap.Connection;rnrnpublic class DB_Util rnrn /**rn * @param argsrn */rn public static void main(String[] args) rn // TODO Auto-generated method stubrnrn rn public java.sql.Connection getconnection()rn try rn Class.forName(com.mysql.jdbc.Driver);rn return DriverManager.getConnection("jdbc://mysql://localhost:3306/jdbc_db", "root", "123456");rn catch (Exception e) rn e.printStackTrace();rn rn return null;rn rn][/code]rn如下图rn[img=https://img-bbs.csdn.net/upload/201702/10/1486702980_636568.png][/img]rn不懂为什么报错 rn
在线等:com.mysql.jdbc.Driver和org.gjt.mm.mysql.Driver的区别
请问用JDBC的驱动rncom.mysql.jdbc.Driver和org.gjt.mm.mysql.Driverrnrn有什么区别!!!!!
(Java项目)无法找到com.mysql.jdbc.Driver的解决方案
        最近在学习JDBC编程,编写如下代码,编译时却报错:java.lang.ClassNotFoundException: com.mysql.jdbc.Driver public class Test1 { public static void main(String[] args) throws Exception { //1.加载驱动,使用反...
Class.forName("com.mysql.jdbc.Driver"); 声明mysql驱动找不到
eclipse + mysql 用jdbc驱动。但是就是找不到驱动。报错红线。rn
MySql的驱动程序:org.gjt.mm.mysql.Driver 和 com.mysql.jdbc.Driver有什么区别??
如题,谢谢。rn我一直用的是com.mysql.jdbc.Driverrn今天在eclipse中使用hibernate工具生成配置文件的时候,发现如果dialect选了mysql5,rn则驱动只能选org.gjt.mm.mysql.Driverrnrn这2个驱动有什么区别呢??
Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
[b][color=#FF0000]请问各位高手怎么解决下面出现的异常,谢谢[/color][/b]rn2009-3-9 9:40:07 org.apache.catalina.core.AprLifecycleListener initrn信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\jdk1.6\bin;D:\tomcat6.0\binrn2009-3-9 9:40:07 org.apache.coyote.http11.Http11Protocol initrn信息: Initializing Coyote HTTP/1.1 on http-8080rn2009-3-9 9:40:07 org.apache.catalina.startup.Catalina loadrn信息: Initialization processed in 1015 msrn2009-3-9 9:40:07 org.apache.catalina.core.StandardService startrn信息: Starting service Catalinarn2009-3-9 9:40:07 org.apache.catalina.core.StandardEngine startrn信息: Starting Servlet Engine: Apache Tomcat/6.0.14rn2009-3-9 9:40:09 org.apache.catalina.core.ApplicationContext logrn信息: ContextListener: contextInitialized()rn2009-3-9 9:40:09 org.apache.catalina.core.ApplicationContext logrn信息: SessionListener: contextInitialized()rn2009-3-9 9:40:09 org.apache.coyote.http11.Http11Protocol startrn信息: Starting Coyote HTTP/1.1 on http-8080rn2009-3-9 9:40:09 org.apache.jk.common.ChannelSocket initrn信息: JK: ajp13 listening on /0.0.0.0:8009rn2009-3-9 9:40:09 org.apache.jk.server.JkMain startrn信息: Jk running ID=0 time=0/31 config=nullrn2009-3-9 9:40:09 org.apache.catalina.startup.Catalina startrn信息: Server startup in 1585 msrnorg.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'rn at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)rn at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)rn at com.xcm.util.DBTool.GetConn(DBTool.java:33)rn at com.xcm.util.DBTool.selectSql(DBTool.java:100)rn at com.xcm.dao.Myentity.select(Myentity.java:12)rn at com.xcm.servlet.bookServlet.LoginServlet(bookServlet.java:71)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at com.xcm.servlet.BasicServlet.doPost(BasicServlet.java:31)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at com.xcm.filter.FilterClass.doFilter(FilterClass.java:27)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at com.xcm.filter.QuanXian.doFilter(QuanXian.java:29)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)rn at java.lang.Thread.run(Thread.java:619)rnCaused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driverrn at java.net.URLClassLoader$1.run(URLClassLoader.java:200)rn at java.security.AccessController.doPrivileged(Native Method)rn at java.net.URLClassLoader.findClass(URLClassLoader.java:188)rn at java.lang.ClassLoader.loadClass(ClassLoader.java:306)rn at java.lang.ClassLoader.loadClass(ClassLoader.java:251)rn at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)rn at java.lang.Class.forName0(Native Method)rn at java.lang.Class.forName(Class.java:169)rn at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1130)rn ... 30 morern
相关热词 c#入门推荐书 c# 解码海康数据流 c# xml的遍历循环 c# 取 查看源码没有的 c#解决高并发 委托 c#日期转化为字符串 c# 显示问号 c# 字典对象池 c#5.0 安装程序 c# 分页算法