Results 1 to 4 of 4
Thread: JDBC compilation error too weird
- 10-24-2012, 09:37 AM #1
Member
- Join Date
- Oct 2012
- Posts
- 21
- Rep Power
- 0
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>
- 10-24-2012, 10:59 AM #2
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.
- 10-24-2012, 01:41 PM #3
Re: JDBC compilation error too weird
Why do they call it rush hour when nothing moves? - Robin Williams
- 11-20-2012, 04:43 AM #4
Member
- Join Date
- Oct 2012
- Posts
- 21
- Rep Power
- 0
Similar Threads
-
Compilation error
By gnarkill10 in forum New To JavaReplies: 2Last Post: 08-05-2012, 03:18 PM -
MIB compilation error - lexical error [0050]
By ajuthani4@hotmail.com in forum NetworkingReplies: 0Last Post: 02-28-2012, 06:09 PM -
compilation error - pls help
By codejava in forum New To JavaReplies: 11Last Post: 09-27-2011, 09:14 AM -
Help with a compilation error
By m_mccutcheon in forum New To JavaReplies: 5Last Post: 08-15-2011, 05:20 PM -
compilation error
By NoufalpRahman in forum Java ServletReplies: 0Last Post: 04-26-2011, 08:08 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks