I'm using NetBeans 8.2 and trying JDBC ODBC Sample code but there is a problem with Java because the JDBC/ODBC brigde was removed.
I searched my problem on the Internet and found that I can use
Jackcess Library
or else I can use thisHXTT
driver, but I don't know how to do it. I'm totally confused and I need help.import java.sql.*; public class SampleDatabase { public static void main(String[] args) { try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); System.out.println("Drivers are properly loaded"); String url="jdbc:odbc:abc"; Connection con = DriverManager.getConnection(url); System.out.println("Connectionn Established"); con.close(); }catch(SQLException e){ System.out.println("SQL ERROR : "+e); }catch(Exception e){ System.out.println("Connection ERROR : "+e); } } }
problem solved
- I was using wrong Driver.
Updated code:
import java.sql.*; public class SampleDatabase { public static void main(String[] args) { try{ Class.forName("com.mysql.jdbc.Driver"); System.out.println("Drivers are properly loaded"); String url="jdbc:mysql://localhost:3306/world"; Connection con = DriverManager.getConnection(url,"root","hcpl"); System.out.println("Connectionn Established"); con.close(); }catch(SQLException e){ System.out.println("SQL ERROR : "+e); }catch(Exception e){ System.out.println("Connection ERROR : "+e); } } }
Asked
Active
Viewed 550 times
1

user207421
- 305,947
- 44
- 307
- 483

JIGNESH VAIDYA
- 11
- 4
-
what exception are you getting? – Vaseph Jan 09 '17 at 12:03
-
Connection ERROR : java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver – JIGNESH VAIDYA Jan 09 '17 at 12:05
-
pls take look at http://stackoverflow.com/questions/22984438/java-lang-classnotfoundexception-sun-jdbc-odbc-jdbcodbcdriver-exception-occurin – Vaseph Jan 09 '17 at 12:14
-
I saw that link which you provided @Vaseph. I've put a jar file (com.mysql.jdbc_5.1.5.jar) in the same package but still I got the same output. – JIGNESH VAIDYA Jan 09 '17 at 12:32
-
com.mysql.jdbc_5.1.5.jar is a JDBC driver specifically for MySQL databases. It won't work with other databases like Access (or SQLite, or SQL Server, ...). – Gord Thompson Jan 09 '17 at 12:37
-
I visited that link which provided me @GordThompson and I tried to solve my problem that way, currently it is not showing me any result but I'll definitely keep trying that way. Maybe a restart can change my output. And thanks for your suggestion for com.mysql.jdbc_5.1.5.jar file. – JIGNESH VAIDYA Jan 09 '17 at 13:10
-
If the MySQL driver fixed your problem you never used MS-Access in the first place. – Jan 10 '17 at 07:26
-
The JDBC-ODBC bridge has been dropped from Java, and this has nothing whatsoever to do with Netbeans. – user207421 Jan 10 '17 at 09:03