3 Replies - 4210 Views - Last Post: 18 October 2012 - 10:54 PM

#1 nepmetal  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 16-October 12

access to database connection not working

Posted 16 October 2012 - 06:13 AM

Hey guys, I am trying to make a simple connection to the a access database(MS Access 2010), but for some reason I am not able to connect to it. I have installed the driver already and this is the sample code. Any help will be highly appreciated.

import java.sql.*;
public class dbConnection {
    
    dbConnection(){
        
        connect();
        
    }
    
    public void connect(){
        
        try{
            
            Class.forName("jdbc.odbc.JdbcOdbcDriver");
            Connection con = DriverManager.getConnection("jdbc:odbc:Database1","","");
            System.out.println("Connected!");
        }
        catch(Exception e){
            
            System.out.println("Error");
            
        }
        
    }
  
   public static void main(String[]args){
       
       new dbConnection();
   }
    
}



Is This A Good Question/Topic? 0
  • +

Replies To: access to database connection not working

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9057
  • View blog
  • Posts: 34,001
  • Joined: 12-June 08

Re: access to database connection not working

Posted 16 October 2012 - 06:49 AM

..moving to the access DB subforum.
Was This Post Helpful? 0
  • +
  • -

#3 nepmetal  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 16-October 12

Re: access to database connection not working

Posted 16 October 2012 - 07:11 AM

View Postmodi123_1, on 16 October 2012 - 06:49 AM, said:

..moving to the access DB subforum.


I'm sorry, very new to this forum. I cant find the access DB subforum.
Was This Post Helpful? 0
  • +
  • -

#4 June7  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 104
  • View blog
  • Posts: 904
  • Joined: 09-December 08

Re: access to database connection not working

Posted 18 October 2012 - 10:54 PM

That is not VBA code you show. What is it? In what application?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1