| Author |
Failed to load JDBC/ODBC driver.
|
Mohd Zaki Mohd Salikon
Greenhorn
Joined: Dec 16, 2004
Posts: 27
|
|
Hi everybody. I'm studying a short java program. This program is using an URL connection. I believe, this code is connect to database using TCP/IP. I was drag the database to my Computer for accessing the data with a standalone system. Can I change this URL code to standalone system?How? Thanks... import java.sql.*; //import all the JDBC classes public class Data { //1 String subjek[] = new String[100] ; int bil=0; public Data() {//2 String URL = "jdbc:ids://161.142.43.224:12/conn?dsn='IDSExamples'"; String username = ""; String password = ""; try { //3 Class.forName("ids.sql.IDSDriver").newInstance(); } //3 catch (Exception e) { //4 System.out.println("Failed to load JDBC/ODBC driver."); return; } //4 Statement stmt = null; Connection con=null; try { //5 con = DriverManager.getConnection (URL); stmt = con.createStatement(); } //5 catch (Exception e) { //6 System.err.println("problems connecting Data to "+URL); } //6 try { //7 execute SQL commands to create table, insert data String query = "SELECT * FROM Kursus Where Kod Like 'T%' "; ResultSet rs = stmt.executeQuery(query); while (rs.next()) {//8 //System.out.println("Kod Kursus: " +rs.getString("Kod")+ " Nama: " +rs.getString("Nama") ); subjek[bil] = new String(rs.getString("Kod")); bil++; }//8 rs.close(); stmt.close(); con.close(); } //7 catch (Exception e) { //9 System.err.println("problems with SQL sent Data to "+URL+": "+e.getMessage()); }//9 }//2 public int getbil() { return bil; } public String[] getsubjek() { return subjek; } public static void main(String[] args) { int bil=0; int i=0; String subjek[]; Data cuba = new Data(); bil = cuba.getbil(); subjek = cuba.getsubjek(); System.out.println("Bilangan semua tempat ialah : " + bil); while (i<bil) { System.out.println("Kod subjek: " + subjek[i]); i++; } } }//1
|
 |
Yu Tao
Greenhorn
Joined: Dec 12, 2004
Posts: 28
|
|
Class.forName("ids.sql.IDSDriver").newInstance(); this is error what is you database??? SQL???Oracle???MysQL???
|
 |
Mohd Zaki Mohd Salikon
Greenhorn
Joined: Dec 16, 2004
Posts: 27
|
|
|
Microsoft Access (Data.mdb). I was setup using JDBC.
|
 |
Mohd Zaki Mohd Salikon
Greenhorn
Joined: Dec 16, 2004
Posts: 27
|
|
|
Thanks. I got it. I'm using the file name of database.
|
 |
 |
|
|
subject: Failed to load JDBC/ODBC driver.
|
|
|