smeacham

DriverManager.getConnection()

Sep 18th, 2012
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. Connection conn = DriverManager.getConnection(
  2.      "jdbc:somejdbcvendor:other data needed by some jdbc vendor",
  3.      "myLogin",
  4.      "myPassword" );
  5. try {
  6.      /* you use the connection here */
  7. } finally {
  8.     //It's important to close the connection when you are done with it
  9.     try { conn.close(); } catch (Throwable ignore) { /* Propagate the original exception
  10. instead of this one that you may want just logged */ }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment