×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
1
Language: Java
Posted by: Minh Pham
Added: Oct 18, 2015 5:16 PM
Views: 6
Tags: odbc dsn
Connect Database throws ODBC DSN
  1. public class Conn_ODBC_DSN {
  2.     Connection conn = null;
  3.     Connection Connect_ODBC_DSN() {
  4.         String dtbName = "";
  5.         String url = "jdbc:odbc:" + dtbName;
  6.         String username = "";
  7.         String password = "";
  8.         try {
  9.             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  10.             conn = DriverManager.getConnection(url,username,password);
  11.             System.out.println("Connected");
  12.         } catch (ClassNotFoundException | SQLException ex) {
  13.             Logger.getLogger(Conn_ODBC_DSN.class.getName()).log(Level.SEVERE, null, ex);
  14. //            System.out.println("Exception");
  15.         }
  16.         return conn;
  17.     }
  18. }