| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1318 人关注过本帖
标题:[求助]java连接mysql得错误!!1
取消只看楼主 加入收藏
mrgreenPB
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-2-27
收藏
 问题点数:0 回复次数:0 
[求助]java连接mysql得错误!!1

import java.sql.*;
public class ConnectMySql {

public static void main(String[] args) {
String sDBDriver="org.gjt.mm.mysql.Driver";
try{
Class.forName(sDBDriver);
}

catch(java.lang.ClassNotFoundException e){
System.out.print("Connect to Database error: " + e.getMessage());
// e.printStackTrace();
System.out.println("----------------------");
}

try {
Statement stmt;
String url ="jdbc:mysql://localhost:3306/mysql";
Connection con =DriverManager.getConnection(url,"root", "hacker");
System.out.println("URL: " + url);
System.out.println("Connection: " + con);
stmt = con.createStatement();
stmt.executeUpdate("CREATE DATABASE JunkDB");
stmt.executeUpdate(
"GRANT SELECT,INSERT,UPDATE,DELETE," +
"CREATE,DROP " +
"ON JunkDB.* TO
'root'@'localhost' " +
"IDENTIFIED BY 'hacker';");
con.close();
}catch( Exception e ) {
e.printStackTrace();
System.out.println(e.toString());
}//end catch
}//end main
}
----------------------------------
下面是错误提示:
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:532)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at ConnectMySql.main(ConnectMySql.java:19)
Connect to Database error: org.gjt.mm.mysql.Driver----------------------
java.sql.SQLException: No suitable driver

搜索更多相关主题的帖子: java mysql 
2006-03-09 16:04
快速回复:[求助]java连接mysql得错误!!1
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019763 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved