提交 1c80f350 编写于 作者: M Mars Liu

fixed pg connection

上级 984e3c83
# PSQL Connection
以下连接postgre数据正确的是:
以下程序中,正确连接postgre数据库的是:
## 答案
......@@ -17,7 +17,7 @@ public class PSQLConnection {
Connection conn = null;
try {
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/test", "root", "root");
conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/test");
Statement stmt = conn.createStatement();
String sql = "CREATE TABLE student " +
......@@ -54,7 +54,7 @@ public class PSQLConnection {
Connection conn = null;
try {
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/test");
conn = new Connection("jdbc:postgresql://dev-cloud.csdn.net:5432/test");
Statement stmt = conn.createStatement();
String sql = "CREATE TABLE student " +
......@@ -89,7 +89,7 @@ public class PSQLConnection {
Connection conn = null;
try {
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection("jdbc:postgresql://root:root@localhost:5432/test");
conn = DriverManager.getConnection("jdbc:postgresql://root+root@localhost:5432/test");
Statement stmt = conn.createStatement();
String sql = "CREATE TABLE student " +
......@@ -124,7 +124,7 @@ public class PSQLConnection {
Connection conn = null;
try {
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection("jdbc:postgresql://localhost/test", "root", "root");
conn = new Connection("jdbc:postgresql://localhost/test", "root", "root");
Statement stmt = conn.createStatement();
String sql = "CREATE TABLE student " +
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册