Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

error in apache

Posted on 2003-03-31
8
Medium Priority
?
170 Views
Last Modified: 2010-04-01
how can i resolve this error??



""""javax.servlet.ServletException: No ResultSet was produced"""""
0
Comment
Question by:gauravg
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 4

Expert Comment

by:thanassis
ID: 8243840
can you post your code?
0
 

Author Comment

by:gauravg
ID: 8244068
<%@ page language="java" import="java.sql.*" %>
<%
     String location = request.getParameter("select1");
     String name = request.getParameter("text1");
     String password = request.getParameter("password1");
     String topic = request.getParameter("text2");
     String msg = request.getParameter("textarea1");

     
     out.println(location);
     out.println(name);
     out.println(password);
     out.println(topic);
     out.println(msg);

Connection connection = null;
String driverString = "sun.jdbc.odbc.JdbcOdbcDriver";
String urlString ="jdbc:odbc:";
String dbString = ";DatabaseName=db1";
String dbUser="";
String dbPassword="";


  try
  {
       Class.forName(driverString);
       connection = DriverManager.getConnection(urlString+dbString, dbUser, dbPassword);
System.out.println("url is " + urlString + dbString);
  }
  catch (Exception exception)
  {
       System.out.println("Connection failed: " + exception.toString());
  }

System.out.println("Connection is " + connection);

String insert_str ="INSERT INTO mail VALUES(?,?,?,?,?)";

int mailno=5;
PreparedStatement insert_pstr = connection.prepareStatement(insert_str);
System.out.println("Statement is prepared");
insert_pstr.setInt(1,mailno);
insert_pstr.setString(2,location);
insert_pstr.setString(3,name);
insert_pstr.setString(4,topic);
insert_pstr.setString(5,"kkkkkkkk");
System.out.println("Executing statement");
insert_pstr.execute();
System.out.println("Statement eXecuted");
String str ="INSERT INTO pas VALUES(?,?)";

PreparedStatement pstr = connection.prepareStatement(str);
pstr.setString(1,name);
pstr.setString(2,password);
pstr.execute();
connection.close();
%>


     
0
 

Author Comment

by:gauravg
ID: 8244075
it's adding data in database but after going to jsp page it gives error
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:thanassis
ID: 8244181
I'm not sure but you can thy this:
change,

PreparedStatement insert_pstr = connection.prepareStatement(insert_str);

with,

CallableStatement insert_pstr  = connection.prepareCall(insert_str);
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 8245788
try this:

<%@ page language="java" import="java.sql.*" %>
<%
    String location = request.getParameter("select1");
    String name = request.getParameter("text1");
    String password = request.getParameter("password1");
    String topic = request.getParameter("text2");
    String msg = request.getParameter("textarea1");

   
    out.println(location);
    out.println(name);
    out.println(password);
    out.println(topic);
    out.println(msg);

Connection connection = null;
String driverString = "sun.jdbc.odbc.JdbcOdbcDriver";
String urlString ="jdbc:odbc:";
String dbString = ";DatabaseName=db1";
String dbUser="";
String dbPassword="";


 try
 {
      Class.forName(driverString);
      connection = DriverManager.getConnection(urlString+dbString, dbUser, dbPassword);
System.out.println("url is " + urlString + dbString);
 }
 catch (Exception exception)
 {
      System.out.println("Connection failed: " + exception.toString());
 }

System.out.println("Connection is " + connection);

String insert_str ="INSERT INTO mail VALUES(?,?,?,?,?)";

int mailno=5;
PreparedStatement insert_pstr = connection.prepareStatement(insert_str);
System.out.println("Statement is prepared");
insert_pstr.setInt(1,mailno);
insert_pstr.setString(2,location);
insert_pstr.setString(3,name);
insert_pstr.setString(4,topic);
insert_pstr.setString(5,"kkkkkkkk");
System.out.println("Executing statement");
insert_pstr.execute();
System.out.println("Statement eXecuted");
String str ="INSERT INTO pas VALUES(?,?)";

PreparedStatement pstr = connection.prepareStatement(str);
pstr.setString(1,name);
pstr.setString(2,password);
pstr.executeUpdate();
connection.close();
%>

Use executeUpdate() instead of excute()

That should fix the problem.

CJ
0
 
LVL 19

Accepted Solution

by:
cheekycj earned 200 total points
ID: 8245795
oops just noticed you had excute twice.. try this:


<%@ page language="java" import="java.sql.*" %>
<%
   String location = request.getParameter("select1");
   String name = request.getParameter("text1");
   String password = request.getParameter("password1");
   String topic = request.getParameter("text2");
   String msg = request.getParameter("textarea1");

   
   out.println(location);
   out.println(name);
   out.println(password);
   out.println(topic);
   out.println(msg);

Connection connection = null;
String driverString = "sun.jdbc.odbc.JdbcOdbcDriver";
String urlString ="jdbc:odbc:";
String dbString = ";DatabaseName=db1";
String dbUser="";
String dbPassword="";


try
{
     Class.forName(driverString);
     connection = DriverManager.getConnection(urlString+dbString, dbUser, dbPassword);
System.out.println("url is " + urlString + dbString);
}
catch (Exception exception)
{
     System.out.println("Connection failed: " + exception.toString());
}

System.out.println("Connection is " + connection);

String insert_str ="INSERT INTO mail VALUES(?,?,?,?,?)";

int mailno=5;
PreparedStatement insert_pstr = connection.prepareStatement(insert_str);
System.out.println("Statement is prepared");
insert_pstr.setInt(1,mailno);
insert_pstr.setString(2,location);
insert_pstr.setString(3,name);
insert_pstr.setString(4,topic);
insert_pstr.setString(5,"kkkkkkkk");
System.out.println("Executing statement");
insert_pstr.executeUpdate();
insert_pstr.close();
System.out.println("Statement eXecuted");
String str ="INSERT INTO pas VALUES(?,?)";

PreparedStatement pstr = connection.prepareStatement(str);
pstr.setString(1,name);
pstr.setString(2,password);
pstr.executeUpdate();
pstr.close();
connection.close();
%>

HTH,
CJ
0
 
LVL 35

Expert Comment

by:girionis
ID: 10078554
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points to cheekycj

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you try to migrate from Elastix to Issabel, you will face a lot of issues. These problems are inevitable but fortunately, you can fix them. In the guide below, I will explain how I performed the migration while keeping all data and successfully t…
Don’ts and Dos are two important end products of software testing basics that a tester needs to regard. This article attempts to explain the principles of both.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses
Course of the Month11 days, left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question