Topic: 求助关于jdbc连接mysql的问题

  Print this page

1.求助关于jdbc连接mysql的问题 Copy to clipboard
Posted by: wj3344
Posted on: 2006-03-30 13:38

为什么连接mysql的时候总是题示no suitable driver
我把mysql的jdbc驱动放在了jdk的目录中了,并且设置的了classpath
使用过几个驱动了,都是这个题示
import java.sql.*;

public class TestJdbc
{
public Connection con;

public TestJdbc()
{

}

public Connection connect()
{
String url="jdbc:mysql:book?useUnicode=true&characterEncoding=8859_1";
String user="root";
String password="123456";

try
{
Class.forName("com.mysql.jdbc.Driver");

}
catch(Exception ex)
{
System.out.println(ex.getMessage());
}

try
{
con=DriverManager.getConnection(url,user,password);

}
catch(Exception ex)
{
System.out.println(ex.getMessage());
}
return con;
}

//main方法在别外一个类中

2.Re:求助关于jdbc连接mysql的问题 [Re: wj3344] Copy to clipboard
Posted by: hoden_w
Posted on: 2006-03-30 17:24

String url ="jdbc:mysql://localhost/book?useUnicode=true&characterEncoding=8859_1";
楼主少了东东!

3.Re:求助关于jdbc连接mysql的问题 [Re: wj3344] Copy to clipboard
Posted by: wj3344
Posted on: 2006-03-31 00:31

谢了二楼的,找到问题了^_^

4.Re:求助关于jdbc连接mysql的问题 [Re: wj3344] Copy to clipboard
Posted by: hoden_w
Posted on: 2006-03-31 11:46

呵呵!不客气!


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923