1.

How Do I Create A Database Connection?

Answer»

The database connection is created in 3 steps:

  1. Find a proper database URL.
  2. Load the database driver.
  3. Ask the Java DriverManager class to OPEN a connection to your database.

In java CODE, the steps are realized in code as follows:

  • CREATE a properly formatted JDBR URL for your database. A JDBC URL has the form jdbc:someSubProtocol://myDatabaseServer/theDatabaseName
  • TRY {
Class.forName("my.database.driver");
}
catch(Exception ex)
{
System.err.println("Could not load database driver: " + ex);
}
  • Connection conn = DriverManager.getConnection("a.JDBC.URL", "databaseLogin", "databasePassword");

The database connection is created in 3 steps:

In java code, the steps are realized in code as follows:



Discussion

No Comment Found