java怎么样通过jdbc连接postgre数据库
来源:百度知道 编辑:UC知道 时间:2024/06/22 11:28:43
String url ="jdbc:postgresql://localhost/myDB"
//myDB为数据库名
String user="myuser";
String password="mypassword";
Connection conn= DriverManager.getConnection(url,user,password);
请给我个完整的代码,我在数据库里建了一个库叫harddisk,
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);
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);
String url ="jdbc:postgresql://localhost:5432/myDB"
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="mypasswor