新建的java工程,测试代码如下,已经把驱动程序拷贝到jre system liabrary 中
package com.test.tao;
import java.sql.*;
public class test {
public static void main(string args[])
{
try{
class.forname(com.mysql.jdbc.driver);
system.out.print(加载数据库成功);
string str=jdbc:mysql://localhost:3306/test?+user=root&password=123456;
connection conn=drivermanager.getconnection(str);
system.out.print(连接成功);
}
catch (exception e)
{system.out.print(连接失败);}
}
}
