Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-06-2009, 07:38 PM
Member
 
Join Date: Jan 2009
Posts: 5
Rep Power: 0
illusion1912 is on a distinguished road
Default Jdbc problem.Help Needed
mport java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Jdbc extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
try {
Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con = DriverManager.getConnection(
"jdbcracle:thin:@localhost:8080:abhishek","sco tt ","tiger");
// @machineNameort:SID, userid, password

out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>Test JDBC Connection</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("<H1>Connection Established Successfully</H1>");
out.println("</BODY>");
out.println("</HTML>");

} catch (ClassNotFoundException e1) {
out.println("Connection Failed " + e1.toString());
} catch (SQLException e2) {
out.println("Connection Failed " + e2.toString());
} catch (Exception e3) {
out.println("Connection Failed " + e3.toString());
}
}

}
this is my code. My Sid is abhishek. am using oracle 9i.apache tomcat application server.But the problem i am facing is i am getting "Connection Failed java.sql.SQLException: Io exception: Got minus one from a read call "... Please help!!!!
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 01-07-2009, 06:14 AM
Member
 
Join Date: Jul 2008
Posts: 68
Rep Power: 0
racerxadam is on a distinguished road
Default
I think you have a typo in your connection string try
Code:
"jdbc:oracle:thin:@localhost:8080:abhishek"
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-08-2009, 07:35 PM
Member
 
Join Date: Jan 2009
Posts: 5
Rep Power: 0
illusion1912 is on a distinguished road
Default No help!!!
have tried it.. but to no avail...what exactly should be the config in server.xml.. what jars do i have to place there? Please help!!!!
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-09-2009, 05:48 AM
Senior Member
 
Join Date: Dec 2008
Location: Hong Kong
Posts: 393
Rep Power: 1
mtyoung is on a distinguished road
Default
which kind of JDBC drivers are you using?
OCI or Thin Driver
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by mtyoung; 01-09-2009 at 05:52 AM.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 01-09-2009, 06:35 AM
Member
 
Join Date: Jul 2008
Posts: 68
Rep Power: 0
racerxadam is on a distinguished road
Default
It might be more helpful if your exception messages were different depending on which exception is thrown. It looks like your code can't find the driver class. Somehow you need to get your driver jar on the classpath of the jvm

And please don't cross post in other forums
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in JDBC Preethi New To Java 11 01-08-2009 05:18 PM
Jdbc problem abhiN Database 1 03-21-2008 05:10 AM
JDBC problem Swamipsn New To Java 1 08-13-2007 06:05 PM
JDBC Driver problem Swamipsn New To Java 3 08-09-2007 03:55 PM
JDBC problem peiceonly Threads and Synchronization 2 08-03-2007 01:42 PM


All times are GMT +2. The time now is 03:01 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org