Hi, Here is a very small Problem. I am trying to access the database thru JSP. Here i
am using class to access. The file names are "SampCon.jsp" which i placed in
"public_html" directory of "JavaWebServer2.0". And created a directory "Asraid" under
that and placed "Connect.java" and made it as package. And even i set the class path.
Here i am providing the codes...
SampCon.jsp:---
<%@ page import="Asraid.*, java.sql.*,java.util.*" errorPage="error.jsp" %>
<html>
<title>Test</title>
<body>
<form name="frm">
<jsp:useBean id="db" scope="page" class="Asraid.Connect" />
<jsp:setProperty name="db" property="*" />
<input type="text" name="Status" value="<%= db.sss() %>" size="25" >
New Status : <%= db.sss() %>
<select name="mod">
<%! String col;
ResultSet res=null;
%>
<%
try{
res = db.getResult();
while( res.next() ){
col = res.getString(1);
%>
<option name="<%= col %>" > <%= col %>
<% }
}catch(SQLException se){
}
%>
</select>
</form>
</body>
</html>
----------------------------------
Connect.java:-------
package Asraid;
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class Connect {
java.sql.Connection aidcon;
String user_id = "aidtest";
String password = "aidtest";
String ipaddress = "172.22.1.171"; //ipaddress of database server
String port = "1521"; //port of database server
String sid = "PAID"; //SID of database server
String dbUrl = "jdbc:oracle:thin:" + user_id + "/" + password + "@" +
ipaddress + ":" + port + ":" + sid;
String name="failure";
Statement stat;
public ResultSet res=null;
public Connect(){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
aidcon = DriverManager.getConnection(dbUrl);
}catch(Exception e){
System.out.println("Hello the error is here");
System.out.println(e);
}
System.out.println("Success");
name = "success";
}
public ResultSet getResult() throws SQLException{
System.out.println("in side get result");
stat = aidcon.createStatement();
res = stat.executeQuery("SELECT UNIQUE(module_typ) FROM
aid_control");
return (res == null ) ? null : res;
}
public String sss(){
return name;
}
public static void main(String args[])throws Exception{
Connect c = new Connect();
System.out.println("Before res");
ResultSet rs = c.getResult();
System.out.println("after res");
while( rs.next()){
System.out.println(rs.getString(1));
}
}
}
--------------------------
Every thing is working fine. I can able to access the "sss" method but if i use
"getResult()" method then it is giving an error ---"java.lang.NoSuchMethodError:
Asraid.Connect:method getResult()Ljava/sql/ResultSet; not found"---
Please help me.
Thanks in advance,
Naren.
Naren,
Programmer Analyst,
SilverLine Technologies,
Chennai.
______________________________________________________
123India.com - India's Premier Portal
Get your Free Email Account at http://www.123india.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets