import java.sql.*;
public class jdbc1 {
public static void main( String args[]) {
String connectionURL = "jdbc:postgresql://localhost:5432/SPS_Sales_DB";
String user="youtilitydba";
String password="Youtility11";
System.out.println("Database connection established");
try {
Class.forName("org.postgresql.Driver");
System.out.println("Driver Connected");
Connection con = DriverManager.getConnection (connectionURL,user,password);
Statement stmt = con.createStatement();
System.out.println("connection created");
ResultSet rs = stmt.executeQuery("select id, model from devices");
while (rs.next())
System.out.println("id= " + rs.getString(1) + rs.getString(2));
con.close();
}
catch (SQLException e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
public class jdbc1 {
public static void main( String args[]) {
String connectionURL = "jdbc:postgresql://localhost:5432/SPS_Sales_DB";
String user="youtilitydba";
String password="Youtility11";
System.out.println("Database connection established");
try {
Class.forName("org.postgresql.Driver");
System.out.println("Driver Connected");
Connection con = DriverManager.getConnection (connectionURL,user,password);
Statement stmt = con.createStatement();
System.out.println("connection created");
ResultSet rs = stmt.executeQuery("select id, model from devices");
while (rs.next())
System.out.println("id= " + rs.getString(1) + rs.getString(2));
con.close();
}
catch (SQLException e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
No comments:
Post a Comment