Created
January 1, 2021 00:17
-
-
Save BGMP/fc527160812ed509269b5a1306a85b3c to your computer and use it in GitHub Desktop.
Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cl.bgmp; | |
import java.sql.Connection; | |
import java.sql.DriverManager; | |
import java.sql.PreparedStatement; | |
import java.sql.ResultSet; | |
import java.sql.SQLException; | |
import java.util.Properties; | |
public class Main { | |
public static void main(String[] args) throws SQLException { | |
Connection connection = null; | |
String pass = "bdi2020m"; | |
String user = "bdi2020m"; | |
try { | |
Class.forName("org.postgresql.Driver"); | |
String url = "jdbc:postgresql://plop.inf.udec.cl/bdi2020m"; | |
Properties props = new Properties(); | |
props.setProperty("user", user); | |
props.setProperty("password", pass); | |
props.setProperty("ssl", "false"); | |
connection = DriverManager.getConnection(url, props); | |
} catch (ClassNotFoundException e) { | |
e.printStackTrace(); | |
return; | |
} | |
PreparedStatement statement = connection.prepareStatement("SELECT * FROM casino"); | |
ResultSet resultSet = statement.executeQuery(); | |
resultSet.next(); | |
System.out.println(resultSet.getString(4)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment