/*
* 数据库连接
*/
package com.xuejava.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class serverdb {
public static Connection getConnection() {
Connection con = null;
try {
System.out.println("正在连接数据库。。。。");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/asda", "fgy", "123456");
System.out.println("已成功连接到数据库");
} catch (SQLException ex) {
System.out.println("连接数据库失败!");
ex.printStackTrace();
}
return con;
}
}