Java: MS Access and JDBC connectivity -
i want connect ms access java code.
how this?
i have written following code:
import java.sql.*; public class test { public static void main(string[] args) { string datasourcename = "test"; string dburl = "jdbc:odbc:" + datasourcename; try { class.forname("sun.jdbc.odbc.jdbcodbcdriver"); connection con = drivermanager.getconnection(dburl, "ify","ify123"); statement statement = con.createstatement(); resultset rs = statement.executequery("select * emp"); system.out.println("hi"); while ( rs.next() ){ system.out.println(rs.getstring(2)); } } catch (exception err) { system.out.println( "error: " + err ); } } }
the problem i'm still not able coneect database. might doing wrong?
this might driver manager registration problem.
you can use alternate statements as:
drivermanager.registerdriver(new sun.jdbc.odbc.jdbcodbcdriver()); connection conn = drivermanager.getconnection(....);
this do.
best of luck!
Comments
Post a Comment