@@ -21,5 +21,19 @@ | |||
<version>5.7.1</version> | |||
<scope>test</scope> | |||
</dependency> | |||
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> | |||
<dependency> | |||
<groupId>mysql</groupId> | |||
<artifactId>mysql-connector-java</artifactId> | |||
<version>8.0.24</version> | |||
</dependency> | |||
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql --> | |||
<dependency> | |||
<groupId>org.postgresql</groupId> | |||
<artifactId>postgresql</artifactId> | |||
<version>42.2.20</version> | |||
</dependency> | |||
</dependencies> | |||
</project> |
@@ -1,8 +0,0 @@ | |||
package cc.javastudio; | |||
public class App { | |||
public static void main(String[] args) { | |||
System.out.println("Hello World"); | |||
} | |||
} |
@@ -0,0 +1,25 @@ | |||
package cc.javastudio; | |||
import java.sql.*; | |||
public class MysqlApp { | |||
public static void main(String[] args) { | |||
String jdbcUrl = "jdbc:mysql://localhost:3306/20210310_bio?useSSL=false"; | |||
String user = "root"; | |||
String pass = "root"; | |||
try { | |||
Connection conn = DriverManager.getConnection(jdbcUrl,user,pass); | |||
Statement stmt = conn.createStatement(); | |||
ResultSet rs = stmt.executeQuery("select * from gwdx_postmeta"); | |||
while (rs.next()) { | |||
String lastName = rs.getString("meta_key"); | |||
System.out.println(lastName); | |||
} | |||
} catch (SQLException throwables) { | |||
throwables.printStackTrace(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,25 @@ | |||
package cc.javastudio; | |||
import java.sql.*; | |||
public class PostgresApp { | |||
public static void main(String[] args) { | |||
String jdbcUrl = "jdbc:postgresql://localhost:5432/dvdrental"; | |||
String user = "postgres"; | |||
String pass = ""; | |||
try { | |||
Connection conn = DriverManager.getConnection(jdbcUrl, user, pass); | |||
Statement stmt = conn.createStatement(); | |||
ResultSet rs = stmt.executeQuery("select * from actor"); | |||
while (rs.next()) { | |||
String firstName= rs.getString("first_name"); | |||
System.out.println(firstName); | |||
} | |||
} catch (SQLException throwables) { | |||
throwables.printStackTrace(); | |||
} | |||
} | |||
} |