This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Servlets and the fly likes cannot connect from servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "cannot connect from servlet" Watch "cannot connect from servlet" New topic
Author

cannot connect from servlet

Lars Vegas
Greenhorn

Joined: Dec 04, 2001
Posts: 27
Hi,
I'm facing a strange behaviour on my tomcat webserver with a servlet. I'm using Oracle 10g as the database and try to access it with my servlet.
The doPost-method throws the following exception while trying to establish the connection to the RDBMS:

"SQLException:
Connecting not possible:
Listener refused the connection with the following error:
ORA-12519, TNS:no appropriate service handler found The Connection descriptor used by the client was: localhost:1521 BTEN"

After starting my servlet, the connection to the database for other applications blocks with the same error message
for a few minutes. After these few minutes connecting to the database is possible again!!! Restarting the database and the listener also helps...



public void doPost( HttpServletRequest request, HttpServletResponse response ) throws IOException, ServletException {

Connection conn = null;

response.setContentType( "text/html" );
PrintWriter out = response.getWriter();

String connStr = "jdbc racle:thin:@localhost:1521 BTEN";
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
}catch( ClassNotFoundException cnf ){
out.println( "CNFException: "+cnf.getMessage() );
}

//retrieve Connection
try{
conn = DriverManager.getConnection( connStr, "scott", "tiger" );
}catch( SQLException sqle ){
out.println( "SQLException: <BR> Connecting not possible: <BR> "+sqle.getMessage()+"<BR>" );
}

.....

}



When I put that part in a 'normal' main program everything is ok. I can connect to the database and access tables with select statements and everything is ok.



public static void main(String[] args) {

Connection conn = null;
//retrieve Connection
try{
String connStr = "jdbc racle:thin:@localhost:1521 BTEN";

try{
Class.forName("oracle.jdbc.driver.OracleDriver");
}catch(ClassNotFoundException cnf){
System.out.println( "CNFException: "+cnf.getMessage() );
}

conn = DriverManager.getConnection( connStr, "scott", "tiger" );

}catch( SQLException sqle ){
System.out.println( "SQLException:"+sqle.getMessage() );
}

.....

}


Does anyone have an idea what the problem is in this case?
I will also post in the Oracle forum
Regards,
Lars
 
 
subject: cannot connect from servlet
 
Similar Threads
ORA-12519 with servlet
Error in connetion pool driver.connect
Problem with conn to oracle
Help needed with error SQLException: ORA-00928: missing SELECT keyword
Not Suitable Driver Error