java连mysql数据库驱动问题
我下载的是mysql-connector-java-5.0.4-bin.jar的JDBC驱动
已经把mysql-connector-java-5.0.4-bin.jar放入jre/lib/ext下面环境变量也设置好 可是数据库联不上 请高手指导。代码如下:
import java.sql.*;
public class DBcon
{
public static void main(String[] args)
{
Connection con;
Statement stmt;
ResultSet rs;
String sName,sId,sdate;
try
{
Class.forName( "com.MySQL.jdbc.Driver ").newInstance();
con=DriverManager.getConnection( "jdbc:MySQL://localhost:3306/test ", "root ", "123456 ");
stmt=con.createStatement();
rs=stmt.executeQuery( "select * from lzs ");
System.out.println( "用户ID "+ "/t "+ "姓名 "+ "/t "+ "生日 ");
while(rs.next())
{
sId=rs.getString( "id ");
sName=rs.getString( "name ");
sdate=rs.getString( "date ");
sId=new String(sId.getBytes( "iso-8859-1 "), "gb2312 ");
sName=new String(sName.getBytes( "iso-8859-1 "), "gb2312 ");
sdate=new String(sdate.getBytes( "iso-8859-1 "), "gb2312 ");
System.out.println(sId+ "/t "+sName+ "/t "+sdate);
}
stmt.close();
con.close();
}
catch(Exception err)
{
System.out.print(err.getMessage());