JDBC-mysql

来源:互联网 发布:淘宝怎么写评论 编辑:程序博客网 时间:2024/05/18 12:41
try{
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/fs";
String username = "root";
String password = "";
Connection conn = DriverManager.getConnection(url,username,password);
if(conn != null)
{
out.print("yes");
conn.close();
}
else
{
out.print("no");
}
}catch(ClassNotFoundException ex){
ex.printStackTrace();
}catch(SQLException ex)
{
ex.printStackTrace();
}
0 0