Results 1 to 4 of 4
  1. #1
    cgk_js is offline Member
    Join Date
    Oct 2012
    Posts
    21
    Rep Power
    0

    Default JDBC compilation error too weird

    I am trying to execute the below simple java program
    but i am getting the below error..
    import java.sql.*;

    class SqlConnection {
    public static void main(String[] args) {
    Connection con = null;
    try
    {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:Driver={Mic rosoft Acess Driver (*.accdb)}; DBQ=C:\\Users\\gopc\\odbc_sql.accdb","","");
    Statement statement = con.createStatement();
    statement.execute("select * from log_entry");
    ResultSet rs = statement.getResultSet();
    if (rs != null)
    {
    while (rs.next())
    {
    System.out.println(rs.getString("date"));
    }
    }
    } catch (Exception e) {
    System.out.println("Error: " + e);
    }
    }
    }

    getting the below compilation error, seems to be too weired.

    C:\Documents and Settings\gopc\workspace\JDBC_Connection\src>javac SqlConnection
    .java
    SqlConnection.java:9: error: incompatible types
    con = DriverManager.getConnection("jdbc:odbc:Driver={Mic
    rosoft Acess Driver (*.accdb)}; DBQ=C:\\Users\\gopc\\odbc_sql.accdb","","");
    ^
    required: Connection
    found: java.sql.Connection
    SqlConnection.java:10: error: cannot find symbol
    Statement statement = con.createStatement();
    ^
    symbol: method createStatement()
    location: variable con of type Connection
    2 errors

    C:\Documents and Settings\gopc\workspace\JDBC_Connection\src>

  2. #2
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    393
    Rep Power
    4

    Default Re: JDBC compilation error too weird

    Seems to me there's a second Connection class wreaking havoc somewhere. Try changing it to java.sql.Connection con = null; and see if that makes any difference.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: JDBC compilation error too weird

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    cgk_js is offline Member
    Join Date
    Oct 2012
    Posts
    21
    Rep Power
    0

    Default Re: JDBC compilation error too weird

    this problem has been resolved..


    basically the issues was the i need to download the JDK for 32 bit for windows 7 and also basically i need to configure the C:\Windows\SysWOW64 to configure
    in the control panel's for configuring the odbc data sources..

Similar Threads

  1. Compilation error
    By gnarkill10 in forum New To Java
    Replies: 2
    Last Post: 08-05-2012, 04:18 PM
  2. MIB compilation error - lexical error [0050]
    By ajuthani4@hotmail.com in forum Networking
    Replies: 0
    Last Post: 02-28-2012, 07:09 PM
  3. compilation error - pls help
    By codejava in forum New To Java
    Replies: 11
    Last Post: 09-27-2011, 10:14 AM
  4. Help with a compilation error
    By m_mccutcheon in forum New To Java
    Replies: 5
    Last Post: 08-15-2011, 06:20 PM
  5. compilation error
    By NoufalpRahman in forum Java Servlet
    Replies: 0
    Last Post: 04-26-2011, 09:08 PM

Posting Permissions

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