You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Riedesel, Chris" <cr...@terraindustries.com> on 2007/06/28 00:46:21 UTC

javax.naming.NamingException: Could not create resource factory i nstance

I am trying to test the connection to an oracle DB from Java on Tomcat 5.5.
The subject is the error I am receiving. 

I am developing using JS Creator 2. When testing the app work fine. But when
it is deployed on our web server the error occurs.

 

Any help, suggestions, example would be great. 

 

Thanks

 

Chris

 

 

My code is 

 

String query = "SELECT * FROM GENUSER.TABLE1 WHERE COLUMN1 = 'a'";

 

try{

Context initCtx = new InitialContext();

Context envCtx = (Context) initCtx.lookup("java:comp/env");

if(envCtx == null ) 

throw new Exception("Boom - No Environment Context");

// the following matches the resource name defined in foo.xml

DataSource ds = 

(DataSource) envCtx.lookup("jdbc/foo");

 

if (ds != null) {

Connection conn = ds.getConnection();

 

if(conn != null) {

Statement stmt = conn.createStatement ();

ResultSet rs = stmt.executeQuery (query);

String strTextArea = "";

while(rs.next()){

//todo

    strTextArea = strTextArea + rs.getString("COLUMN1") ;

}

this.textArea1.setText(strTextArea );

// important to cleanup

rs.close();

stmt.close();

conn.close();

} else {

throw new Exception("No Connection");

}

} else {

throw new Exception("No Datasource");

}

} catch(SQLException ex) {

 

while (ex != null) { 

ex = ex.getNextException ();

} // end while

 

} // end catch SQLException

catch(NamingException ex) {

ex.printStackTrace();

}

catch(Exception ex) {

ex.printStackTrace();

}