新手求指点,连接数据库相关
请看一下这是什么原因导致的。这是控制台的输出:
具体应该怎么弄?请说清楚一些,新手~谢~
2012-5-9 9:42:16 com.ibatis.common.logging.jdk14.Jdk14LoggingImpl error
严重: SimpleDataSource: Error while loading properties. Cause: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.ibatis.common.resources.Resources.classForName(Resources.java:267)
at com.ibatis.common.resources.Resources.instantiate(Resources.java:283)
at com.ibatis.common.jdbc.SimpleDataSource.initialize(SimpleDataSource.java:199)
at com.ibatis.common.jdbc.SimpleDataSource.<init>(SimpleDataSource.java:116)
at com.ibatis.sqlmap.engine.datasource.SimpleDataSourceFactory.initialize(SimpleDataSourceFactory.java:31)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$9.process(SqlMapConfigParser.java:220)
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:121)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:105)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:72)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:46)
at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63)
at Exec.OperateDatebase.<clinit>(OperateDatebase.java:24)
at test.test.main(test.java:18)
java.lang.RuntimeException: Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/transactionManager/dataSource/end()'. Cause: com.ibatis.sqlmap.client.SqlMapException: Error initializing DataSource. Could not instantiate DataSourceFactory. Cause: java.lang.RuntimeException: SimpleDataSource: Error while loading properties. Cause: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:49)
at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63)
at Exec.OperateDatebase.<clinit>(OperateDatebase.java:24)
at test.test.main(test.java:18)
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/transactionManager/dataSource/end()'. Cause: com.ibatis.sqlmap.client.SqlMapException: Error initializing DataSource. Could not instantiate DataSourceFactory. Cause: java.lang.RuntimeException: SimpleDataSource: Error while loading properties. Cause: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:46)
... 3 more
Caused by: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/transactionManager/dataSource/end()'. Cause: com.ibatis.sqlmap.client.SqlMapException: Error initializing DataSource. Could not instantiate DataSourceFactory. Cause: java.lang.RuntimeException: SimpleDataSource: Error while loading properties. Cause: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:123)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:105)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:72)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51)
... 4 more
Caused by: com.ibatis.sqlmap.client.SqlMapException: Error initializing DataSource. Could not instantiate DataSourceFactory. Cause: java.lang.RuntimeException: SimpleDataSource: Error while loading properties. Cause: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$9.process(SqlMapConfigParser.java:227)
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:121)
... 9 more
Caused by: java.lang.RuntimeException: SimpleDataSource: Error while loading properties. Cause: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at com.ibatis.common.jdbc.SimpleDataSource.initialize(SimpleDataSource.java:210)
at com.ibatis.common.jdbc.SimpleDataSource.<init>(SimpleDataSource.java:116)
at com.ibatis.sqlmap.engine.datasource.SimpleDataSourceFactory.initialize(SimpleDataSourceFactory.java:31)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$9.process(SqlMapConfigParser.java:220)
... 10 more
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.ibatis.common.resources.Resources.classForName(Resources.java:267)
at com.ibatis.common.resources.Resources.instantiate(Resources.java:283)
at com.ibatis.common.jdbc.SimpleDataSource.initialize(SimpleDataSource.java:199)
... 13 more
Exception in thread "main" java.lang.NullPointerException
at Exec.OperateDatebase.insertPerson(OperateDatebase.java:33)
at test.test.main(test.java:18)
[解决办法]
没有数据库驱动
[解决办法]
把数据库驱动放到自己的项目中
[解决办法]
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
加入MySQL java 驱动即可