By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,654 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,654 IT Pros & Developers. It's quick & easy.

Error in createStatement() "incompatible types"

P: 4
im trying to connect to the database and thier is an error in the createstatemnet thats is "incompatable types required is java.beans.Statemnet and found java.sql.Statement "
any one can help me in this error
thanx .

Expand|Select|Wrap|Line Numbers
  1.   static Connection connection;
  2.             static Statement statement;
  3.  
  4.  
  5.  
  6.             public static void SetupConn(){
  7.  
  8.     try {
  9.       // Step 1: Load the JDBC driver.
  10.       Class.forName("org.hsqldb.jdbcDriver");
  11.       System.out.println("Driver Loaded.");
  12.       // Step 2: Establish the connection to the database.
  13.       String url = "jdbc:hsqldb:data/tutorial";
  14.  
  15.       connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "scott", "tiger");
  16.       System.out.println("Got Connection.");
  17.  
  18.       statement = connection.createStatement();
  19.     } catch (   ClassNotFoundException | SQLException e) {
  20.       System.err.println("Got an exception! ");
  21.       System.exit(0);
  22.     }
  23.   }
  24.  
  25. }      
  26.  
Nov 25 '12 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,421
The error message is fairly clear, your statement variable is a java.beans.statement while connection.createStatement() returns a java.sql.statement. You should create your statement variable as a java.sql.statement type.
Nov 25 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.