CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2000
    Location
    Israel
    Posts
    403

    Urgent help to C++ programmer about JDBC

    I am using Java 1.1 (from Sun) on Windows98 platform. I have a problem that I cannot connect to a database through Jdbc:Odbc and I need it urgently (very).
    Suppose I have a MS Access database called "FirstTry.MDB" stored for example in the path c:\My Documents\aaa\bbb.
    So the full path is "c:\My Documents\aaa\bbb\FirstTry.MDB"
    Is anybody able to write a piece of Java code (Java 1.1) that will connect me to it.
    I will thank for any help.
    Thank you.

    There is no need to markup

  2. #2
    Guest

    Re: Urgent help to C++ programmer about JDBC

    As far as I know, you first have to regiser your ODBC-source. Do this by selecting "ODBC data sources" in the system settings window, clicking the "System DSN" tab and specifying "Acess driver", your path and a name for the data source(eg. "FirstTry"). Then, in your Applet, the following lines of code should establish a connection:

    import java.sql.*;
    void init() {
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbcdbc:FirstTry", "", "");
    } catch(Exception e) {
    //display error message
    }






Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured