I am connecting to an oracle database using a connection pool. I have set up my datasource file but when I try to get a connection I get the error
The method getConnection() is undefined for the type DataSource
I have searched the internet and it doesn’t seem to be a common problem. I am not sure what I have done wrong.
The code is:
<datasources>
<local-tx-datasource>
<jndi-name>DefaultDS</jndi-name>
<connection-url>jdbc:oracle:thin:@ED.OPTO:1521:OPY>
<driver-class>oracle.driver.OracleDriver</driver-class>
<user-name>temiuser</user-name>
<password>password</password>
</local-tx-datasource>
import javax.activation.DataSource;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.sql.*;
import javax.sql.*;
public class dataSource {
// load the driver
Class.forName("oracle.jdbc.OracleDriver");
String sourceFile = "java:/TVEContent";
InitialContext ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup(sourceFile);
Connection conn = ds.getConnection();
Statement stmnt = conn.createStatement("select * from tve");
}
Please help!!!!
Name clash:
import javax.sql.DataSource;BTW should it not be
ic.lookup("DefaultDS")(unsure at the moment)?