Need help!!!

Discussion in 'Java' started by JackDaniels, Oct 9, 2009.

  1. JackDaniels

    JackDaniels New Member

    Joined:
    May 31, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Hello everyone, can someone help me with this please?
    Create class which will create tables in data base (Microsoft Access). About the tables: number of columns, type of data, lenght of the data.
    And mantaining the information (the data) in the tables- add data, delete data and edit data.
    Thank you!
     
  2. JackDaniels

    JackDaniels New Member

    Joined:
    May 31, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Here's some code so far, but it's connected with SQL and I need it with Access.
    Code:
    import java.sql.*;
    
    public class CreateTable{
      public static void main(String[] args) {
        System.out.println("Table Creation Example!");
        Connection con = null;
        String url = "jdbc:mysql://localhost:3306/";
        String dbName = "jdbctutorial";
        String driverName = "com.mysql.jdbc.Driver";
        String userName = "root";
        String password = "root";
        try{
          Class.forName(driverName).newInstance();
          con = DriverManager.getConnection(url+dbName, userName, password);
          try{
            Statement st = con.createStatement();
            String table = "CREATE TABLE Employee11(Emp_code integer, Emp_name varchar(10))";
            st.executeUpdate(table);
            System.out.println("Table creation process successfully!");
          }
          catch(SQLException s){
            System.out.println("Table all ready exists!");
          }
          con.close();
        }
        catch (Exception e){
          e.printStackTrace();
        }
      }
    }
    
    Any help?
     
  3. JackDaniels

    JackDaniels New Member

    Joined:
    May 31, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    The question is this: I work in Eclipse. How to connect Eclipse with Access?
    The code is just fine, it has no errors.
    The errors that the code is giving me are:
    Code:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Could not find file '(unknown)'.
    	at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
    	at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
    	at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
    	at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
    	at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
    	at java.sql.DriverManager.getConnection(Unknown Source)
    	at java.sql.DriverManager.getConnection(Unknown Source)
    	at dbAccess.main(dbAccess.java:12)
    
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice