I am trying to execute the query from my Main class by calling the connection object from another class named "Conection".But I have been getting the following error.I have included the source code and also the errors.Please advise:
//This is the main class:
package esperimentbase;
import java.sql.*;
/**
*
* @author Saptarshi
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(
String[] args)throws ClassNotFoundException,SQLException
{
Conection conn1=new Conection();
Statement stmt=conn1.createStatement();
ResultSet rset=stmt.executeQuery("select 'Hello thin driver tester'||USER||'!' result from dual")
while(rset.next())
{
System.out.println(rset.getString(1));
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Tjis is the conection class from which I am connecting
JDBC to Oracle
package esperimentbase;
import java.sql.*;
/**
*
* @author Saptarshi
*/
public class Conection
{
public Connection conn;
public Conection()throws ClassNotFoundException,SQLException
{
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("OK :/");
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:XE","System","orion");
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
The error that I am getting is
Exception in
thread "main" java.lang.RuntimeException: Uncompilable source code - incompatible types
found : esperimentbase.Conection.createStatement
required: java.sql.Statement
at esperimentbase.Main.main(Main.java:24)
PLEASE ADVISE