Quote:
Originally Posted by muffaddalDBA
if table exists then check table previledge if its high level
qualifier for - ds.getConnection("gururaj", "sdmcet");
|
i am sending these both files with little bit changes
as per ur suggestion.
One more query, how to check the privilages of table. Plz guide me. Thank you.
feed.jsp
<%@ 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="check_feedback.jsp" method="post">
<table width="475" border="1">
<tr>
<td width="219">FNAME:</td>
<td width="240"><input type="text" name="name1"></td>
</tr>
<tr>
<td>MNAME:</td>
<td><input type="text" name="age1"></td>
</tr>
<tr>
<td>LNAME:</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>
<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");
int ch=0;
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);
//String u="jdbc:db2://localhost:50000/EXAMPLE1";
// get connection
java.sql.Connection con=null;
java.sql.Statement stmt = null;// con.createStatement();
try{
con = ds.getConnection("gururaj","sdmcet");
stmt = con.createStatement();
out.print("OK");
// java.sql.Statement stmt = con.createStatement();
ch=1;
} catch(Exception e)
{
out.print(""+e);
out.print("r"+ch);
}
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+")";
//OR
//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="success.jsp"></jsp:forward>
<%
rs.close();
stmt.close();
con.close();
}
catch(Exception e)
{
out.println("Error "+e.getMessage());
%>
<h1>error</h1>
<%
}
%>
</body>
</html>