codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  DB2 Query Problem  guruk2k5 at 10:07 on Thursday, March 25, 2010
 

Hi all. I am using DB2 as back end. and i able to insert the query manually. but through jsp i am getting an exception. IN DB all fields are type VARCHAR.
i am new to DB2 and JSP. Plz help

<b>feed.jsp</b>
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<form action="/forum/check_feedback.html" method="post">
<table width="475" border="1">
<tr>
<td width="219">NAME:</td>
<td width="240"><input type="text" name="name1"></td>
</tr>
<tr>
<td>AGE:</td>
<td><input type="text" name="age1"></td>
</tr>
<tr>
<td>RNO:</td>
<td><input type="text" name="rno1"></td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" name="Submit" value="Submit">
</div>
</td>
</tr>
</table>
</form>

</body>
</html>

check_feedback.jsp




<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<html>
<head>
<link rel="stylesheet"
href="${pageContext.request.contextPath}/theme/Master.css"
type="text/css">
<title>check_feedback</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="GENERATOR" content="Rational Application Developer">
</head>
<body>
<% String temp1=(String) request.getParameter("name1");
String temp2=(String) request.getParameter("age1");
String temp3=(String) request.getParameter("rno1");

try {
// create data source
com.ibm.db2.jcc.DB2SimpleDataSource ds =
new com.ibm.db2.jcc.DB2SimpleDataSource();

// set connection properties
ds.setServerName("localhost");
ds.setPortNumber(50000);
ds.setDatabaseName("example1");
ds.setDriverType(4);

// get connection
java.sql.Connection con = ds.getConnection("gururaj", "sdmcet");


java.sql.Statement stmt = con.createStatement();
java.sql.ResultSet rs = null;
%><table><tr><td>
<%out.println(temp1+"\n");%>
</td>
</tr>
<tr>
<td>
<%out.println(temp2+"\n");%>
</td>
</tr>
<tr>
<td>
<%out.println(temp3+"\n");%>
</td>
</tr>
</table>
<%
rs.refreshRow();
rs.moveToCurrentRow();
// rs.moveToInsertRow();

//String query="INSERT INTO gururaj.SAMPLE ('NAME',AGE,RNO) VALUES ("+temp1+","+temp2+","+temp3+")";
//String query="INSERT INTO gururaj.SAMPLE VALUES('temp1','temp2','temp3')";
String query="INSERT INTO gururaj.SAMPLE VALUES ('"+temp1+"','"+temp2+"','"+temp3+"')";
stmt.executeUpdate(query);

//stmt.executeQuery(query);
%>


<jsp:forward page="/forum/success.html"></jsp:forward>
<%
rs.close();
stmt.close();
con.close();
}
catch(Exception e)
{
out.println("Error "+e.getMessage());

%>

<h1>error</h1>
<%
}




%>

</body>
</html>

input
t
t
t
in all three textboxes

output
t
t
t
Error null
error








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: How to run ASP code on server automatically wrt date & time
•  Re: Running ASP Program From Visual Basic Form
•  Re: PHP swapping images
•  Re: dereferenceing a string to a constant name
•  DB2 Query Problem
•  Re: How to make href enabled and disabled???
•  Re: where can i download javax.speech package
•  Re: Can javascript preload swf files?
•  Re: Can javascript preload swf files?


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2010