Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to read .odb file in java using JDBC?

For .mdb files we use the following code

import java.sql.*;

class Odbctest1 { public static void main(String args[]) { try { Class.forName("sun.jdbc.odbc.jdbcodbcDriver"); Connection con; con=DriverManager.getConnection("jdbc:odbc:myDB","","");
Statement s=con.createStatement(); ResultSet rs; System.out.println("hai....\n"); String q="select * from \"Table1\""; rs=s.executeQuery(q); System.out.println("rollno\t\tname\t\tdept\t\tyear\t\taddress"); System.out.println("-----\t\t----\t\t----\t\t-----\t\t------"); while(rs.next()) { System.out.print(rs.getString(1)+"\t\t"); System.out.print(rs.getString(2)+"\t\t"); System.out.print(rs.getString(3)+"\t\t"); System.out.print(rs.getString(4)+"\t\t"); System.out.println(rs.getString(5)+"\t\t"); } } catch(Exception e) { System.out.println("Error"+e); } }

For .odb files we are not able to find any code for the same.

How to read .odb file in java using JDBC?

For .mdb files we use the following code

import java.sql.*;

class Odbctest1 { public static void main(String args[]) { try { Class.forName("sun.jdbc.odbc.jdbcodbcDriver"); Connection con; con=DriverManager.getConnection("jdbc:odbc:myDB","","");
Statement s=con.createStatement(); ResultSet rs; System.out.println("hai....\n"); String q="select * from \"Table1\""; rs=s.executeQuery(q); System.out.println("rollno\t\tname\t\tdept\t\tyear\t\taddress"); System.out.println("-----\t\t----\t\t----\t\t-----\t\t------"); while(rs.next()) { System.out.print(rs.getString(1)+"\t\t"); System.out.print(rs.getString(2)+"\t\t"); System.out.print(rs.getString(3)+"\t\t"); System.out.print(rs.getString(4)+"\t\t"); System.out.println(rs.getString(5)+"\t\t"); } } catch(Exception e) { System.out.println("Error"+e); } }

For .odb files we are not able to find any code for the same.