Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:

C#
import java.sql.*;
public class Main
{
    private static final String accessDBURLPrefix = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
    private static final String accessDBURLSuffix = ";DriverID=22;READONLY=false}";
    // Initialize the JdbcOdbc Bridge Driver
    static {
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        } catch(ClassNotFoundException e) {
            System.err.println("JdbcOdbc Bridge Driver not found!");
        }
    }
    public static Connection getAccessDBConnection(String filename) throws SQLException {
        String databaseURL = accessDBURLPrefix + filename + accessDBURLSuffix;
        return DriverManager.getConnection(databaseURL, "", "");
    }
    public static void main(String[] args)
    {
        try
        {
            Connection conn = getAccessDBConnection("User.mdb");
            Statement s = conn.createStatement();
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }
}
Posted
Updated 9-Jul-10 13:32pm
v3
Comments
Richard MacCutchan 10-Jul-10 6:46am    
Looks good, do you have a question?
husseinx 10-Jul-10 22:58pm    
how can i fix this exeption???
can u help??

1 solution

FOR USING JDBC AND HIBERNATE IT'S BETTER USE SHINE ENTERPRISE LIBRARY

IT DO ALL SETTING FOR YOU

IT'S VERY EASY AND FASTER

http://SourceForge.net/projects/shine-enterpris/files/[^]
 
Share this answer
 
Comments
husseinx 11-Jul-10 21:56pm    
can u give an example how can i use it??
10xx for u help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900