java中 MySQL与驱动jdbc连接不上,想请教高手:jdbc驱动:mysql-connector-java-5.1.18-bin.jar怎么用啊?

连接数据库的一段代码如下:(高手们你们看看有问题么??)Driverdriver=newcom.mysql.jdbc.Driver();DriverManager.reg... 连接数据库的一段代码如下:(高手们你们看看有问题么??)
Driver driver = new com.mysql.jdbc.Driver();
DriverManager.registerDriver(driver);
String url = "jdbc:mysql://localhost:3306/bookstore";
String user = "root";
String password = "123";
int i=0;
Class.forName("com.MySQL.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection(url, user, password);
if(!conn.isClosed())
System.out.println("连接数据库成功!");
statement= conn.createStatement();

}
报错如下:(总是说没有连接jdbc驱动,大神们!!用mysql时,jdbc应该怎么放或者配置啊???求教啊!!!)
java.lang.ClassNotFoundException: com.MySQL.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at connectmsl.Test.<init>(Test.java:27)
at connectmsl.Admin.actionPerformed(Admin.java:59)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
展开
 我来答
汪雄辉拉
2012-03-23 · TA获得超过2966个赞
知道大有可为答主
回答量:1430
采纳率:0%
帮助的人:1624万
展开全部
Class.forName("com.MySQL.jdbc.Driver").newInstance();
改成 com.mysql.jdbc.Driver
308879263
2012-03-23 · 超过47用户采纳过TA的回答
知道答主
回答量:118
采纳率:0%
帮助的人:96.8万
展开全部
MYSQL改小写是必须的。不过你还要把这个jar包放到你项目的lib文件夹里面去,这样他才能找到撒。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
李越弘
2012-03-23
知道答主
回答量:33
采纳率:0%
帮助的人:25.2万
展开全部
那个mysql-connector-java-5.0.8-bin.jar你加上试试!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
恋上师妹的床
2012-03-23
知道答主
回答量:14
采纳率:0%
帮助的人:6.4万
展开全部
楼上正解,还有就是要中入mySql数据库的jar驱动包
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式