Class.forName("org.postgresql.Driver").newInstance();
String url ="jdbc:postgresql:5432//localhost/harddisk"
//myDB为数据库名
String user="myuser";
String password="mypassword";
Connection conn= DriverManager.getConnection(url,user,password);
public class Class1{
static{
Class.forName("org.postgresql.Driver")
}
public void main(String[] args){
String url ="jdbc:postgresql://localhost:5432/myDB"
//myDB为数据库名
String user="myuser";
String password="mypassword";
Connection conn= DriverManager.getConnection(url,user,password);
}
}