June 2018
Beginner
722 pages
18h 47m
English
Here is the code fragment to connect to the database:
String URL = "jdbc:postgresql://localhost/javaintro";Properties prop = new Properties( );//prop.put( "user", "java" );//prop.put( "password", "secretPass123" );try { Connection conn = DriverManager.getConnection(URL, prop);} catch(SQLException ex){ ex.printStackTrace();}
The commented lines show how you can set a user and password for your connection using the java.util.Properties class. The preceding is just an example of how to get a connection using the DriverManger class directly. Many keys for the passed-in properties are the same for all major databases, but some of them are database-specific. So, read your database vendor documentation for such details. ...
Read now
Unlock full access