• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error :SQLException caught:Io exception: Got minus one from a read call

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
i have created the following servlet which i want to connect to oracle 10g.

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
}

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Connection con = null;
String driver = "oracle.jdbc.driver.OracleDriver";
String serverName ="devaki";
String portNumber = "8081";
String sid = "";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber+ ":" + sid;

String username = "system";
String password = "tiger";





PrintWriter out = response.getWriter();

//Retrieving values from HTML page
String CourseName=request.getParameter("CourseName");

String CourseId=request.getParameter("CourseId");
String CourseCapacity=request.getParameter("CourseCapacity");
String CourseDesc=request.getParameter("CourseDesc");
String CourseDuration=request.getParameter("CourseDuration");

try {

Class.forName(driver);
con = DriverManager.getConnection(url, username,password);


String sql = "insert into Course values(?,?,?,?,?)";
PreparedStatement pst = con.prepareStatement(sql);

pst.setString(1, CourseId);
pst.setString(2, CourseName);
pst.setString(3, CourseCapacity);
pst.setString(4, CourseDesc);
pst.setString(5, CourseDuration);


pst.executeUpdate();
pst.close();



pst.close();
con.close();
}

catch (ClassNotFoundException e){
out.println("Couldn't Load database driver: "+e.getMessage());
}

catch (SQLException e){
out.println("SQLException caught:"+e.getMessage());
}

catch (Exception e) {
out.println(e); }
finally
{
try
{
if (con!= null)
con.close();
}
catch(SQLException ignored)
{

out.println(ignored);

}
}
}
}


I am getting the error SQLException caught:Io exception: Got minus one from a read call
I think that he error is at the line con = DriverManager.getConnection(url, username,password);
My servlet is not getting connected to the database.
Is it because i also have oracle 8i installed on my machine.Do I need to uninstall it first?
I am using Eclipse Ganymede for execution of the servlet

Any help will be appreciated
Thanks
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you able to connect to 10g from sql prompt? What is port no 8081 here, is the port number of db service?
 
devaki hanumante
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes.I can login to 10g from the sql prompt.
8081 is the db port no.The home page of 10g is opening correctly.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it connecting using jdbc-odbc bridge? If it connects might have got something to do with the driver.
 
devaki hanumante
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried using the tomcat server
it is giving the following output

null
Couldn't Load database driver: oracle.jdbc.driver.OracleDriver

So I thik there is a problem with the driver.Do you need to set any environment variables to make the driver work.If yes,what are those
Thanks
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have you copied ojdbc14.jar or ojdbc14_g.jar to WEB-INF\lib of your application folder while testing from tomcat?
 
devaki hanumante
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes i did
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you still got the same error oracle.jdbc.driver.OracleDriver?
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whats your jdk version?
 
devaki hanumante
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have jdk 1.5
I had copied the jar files in lib in eclipse
then it gave me the null
SQLException caught:Io exception: Got minus one from a read call error

When I copy the files to tomcat web apps it is giving me the same error
What could be the problem?
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have you tried jdbc-odbc bridge? If it connects might be some thing with driver or else might be something with network setup.
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi devaki,

check the sid, you have left out that...hope that is the datasource you need to connect..

 
reply
    Bookmark Topic Watch Topic
  • New Topic