once again hi to all,
now i am facing with new problem since 5 days. now i am putting in front ao ypu people. can any one tell where i am wrong.
here i am trying to get the data from the database mysql using
jsp. here i am using package concept of
java and i wrote two java programs namely connect.java which is placed inside connection package and SqlBean.java which is placed inside package sq.
i am placing my code
connect.java
--------------
package connection;
import java.sql.DriverManager;
import java.sql.Connection;
import java.io.*;
public class connect
{
Connection conn;
public connect()
{
try{
Class.forName("com.mysql.jdbc.Driver");
}
catch(Exception e)
{
System.out.println(e);
}
}
public Connection getConnection()
{
try{
conn=DriverManager.getConnection("mysql:mysql://localhost/hello","root","root");
}catch(Exception e)
{
System.out.println(e);
}
return conn;
}
}
---------------------------
SqlBean.java
------------
package sq;
import connection.*;
import java.sql.*;
public class SqlBean
{
Connection con=null;
public SqlBean()
{
connect c=new connect();
con=c.getConnection();
}
// Insert the records into database
public
String insert(String query)
{
int i=0;
try
{
//Statement st=con.createStatement();
//i=st.executeUpdate(query);
//System.out.println("hi");
//return query;
}
catch(Exception e)
{
System.out.println(e);
}
return query;
}
// it is used to select the records based on Query
public ResultSet selection(String query)
{
ResultSet rs=null;
*try
{
Statement st=con.createStatement();
rs=st.executeQuery(query);
//return rs;
}
catch(Exception e)
{
System.out.println(e);
}
return rs;
}
// to close the connection (con)
public void close()
{
try
{
if(con!=null)
{
con.close();
}
}catch(Exception e)
{
System.out.println(e);
}
}
}
------------------------------------------
and my jsp code as follows
tes.jsp
--------
<%@ page import="java.sql.*" session="false" %>
<jsp:useBean id="s" class="sq.SqlBean" scope="page" />
<%!String str1;%>
<%
str1="select * from how";
ResultSet rs=s.select(str1);
//String qq=s.insert("hello")
//out.println(qq);
while (rs.next())
{
//here code to retrive all the fields ok
}
%>
--------------------------------------
can any one tell wher i am doing mistake.
i am not getting any errors while compailing .java programs
Exceptions what i am getting as follows
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the jsp file: /te.jsp
The method select(String) is undefined for the type SqlBean
3: <%!String str1;%>
4: <%
5: str1="select * from how";
6: ResultSet rs=s.select(str1);
7: //String qq=s.insert("hello")
8: //out.println(qq);
9: while (rs.next())
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
waiting for you people reply
[edited subject to be more descriptive - was "can any one help me"]
[ April 07, 2007: Message edited by: Jeanne Boyarsky ]
[ April 07, 2007: Message edited by: Narasimha Raju Naidu ]