tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Riedesel, Chris" <criede...@terraindustries.com>
Subject javax.naming.NamingException: Could not create resource factory i nstance
Date Wed, 27 Jun 2007 22:46:21 GMT
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();

}


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message