Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

raji navaneethan

Greenhorn
+ Follow
since Apr 06, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by raji navaneethan

Hi,

How to Deploy webapplications on weblogic server..
Anyone help me??

Thanx in advance
14 years ago
Hi,

Tillnow am using notepad.I want to use Jcreator editor.I haven't any idea about how to use jsp in Jcreator.Now Am using ApacheTmacat4.0 is my Webserver.

Anyone help me to this Query.It's very Urgent for me
Thanx in advance
14 years ago
JSP
Hi, am new to this field.I haven't idea about Hashmap.But i wrote this pgm it is perfectly working(Fetching the data from database).But I don't know abt this process is correc or not.
Anyone help me .Urgently I need this one

Thanx in advance

<HTML>
<HEAD><TITLE>DataBase Search</TITLE></HEAD>
<BODY leftmargin=300>

<%@ page language="Java" import="java.sql.*" %>
<%@ page import="SQLBean.*" %>
<%@ page import ="java.util.*"%>
<%ArrayList alReturn = new ArrayList();%>


<jsp:useBean id="db" scope="application" class="SQLBean.DbBean" />
<jsp:setProperty name="db" property="*" />
<%!
ResultSet rs = null ;
ResultSetMetaData rsmd = null ;
int numColumns ;
int i;
String empno = "";
String age = "";
String fname = "";
String salary="";
%>


<h2> Results from Database</h2>

<br><br>

<%
try {
int loop;
int loop1;
HashMap hmInner = null;
int intCount = 0;
String strElement = "";
db.connect();
rs = db.execSQL("select * from employ"); %><%
db.connect();
i = db.updateSQL("UPDATE employ set fname = 'vijaya' where empno='vss09'");
out.println(i+"records are inserted");%><br><br>
<%rsmd = rs.getMetaData();
intCount = rsmd.getColumnCount();
out.println("Number of Columns "+intCount);%><br><br>

<%for (loop1 = 1; loop1 <= intCount; loop1++)
{%>
<b><%out.println(rsmd.getColumnName(loop1));%>      </b><%
}%><br><br>

<%
while(rs.next())
{
hmInner = new HashMap();
for (loop = 1; loop <= intCount; loop++)
{
strElement = rs.getString(loop);
if (strElement == null)
{
strElement = "";
}

if (!strElement.equals(""))
{
hmInner.put(rsmd.getColumnName(loop),strElement);
}

}


if (hmInner.size() > 0)
{
alReturn.add(hmInner);
}

}

}


catch(SQLException e)
{
throw new ServletException("Your query is not working", e);
}
%>
<%
int iSize = 0;

HashMap hmResult = null;

if(alReturn!=null & alReturn.size() > 0){

iSize = alReturn.size();
out.println("Number of Rows "+iSize );

for(int i = 0; i < iSize; i++){

hmResult = (HashMap)alReturn.get(i);
%>
<table cellpadding="2" cellspacing="1" border="0" width="61%"><tr><td width="35%" align="left" bgcolor="#E5ECF9"><b>
<%empno = (String) hmResult.get("empno");out.println(empno);%></b></td><td width="35%" align="left" bgcolor="#E5ECF9"><b>
<%age = (String) hmResult.get("age");out.println(age);%></b></td><td width="35%" align="left" bgcolor="#E5ECF9"><b>
<%fname = (String) hmResult.get("fname");
out.println(fname);%></b></td>
<td width="35%" align="left" bgcolor="#E5ECF9"><b><%salary = (String) hmResult.get("salary");
out.println(salary);%></b></td>
</tr></table><%}}
%>


</body>
</HTML>



package SQLBean;
import java.sql.*;
import java.io.*;

public class DbBean implements java.io.Serializable{
private String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
private Connection dbCon;

public DbBean(){
super();
}

public boolean connect() throws ClassNotFoundException,SQLException{
Class.forName(dbDriver);
dbCon = DriverManager.getConnection("jdbc dbc:mybean","","");
return true;
}




public void close() throws SQLException
{
dbCon.close();
}


public ResultSet execSQL(String sql) throws SQLException{
Statement s = dbCon.createStatement();
ResultSet r = s.executeQuery(sql);
return (r == null) ? null : r;
}

public int updateSQL(String sql) throws SQLException{
Statement s = dbCon.createStatement();
int r= s.executeUpdate(sql);
return (r == 0) ? 0 : r;
}

}
14 years ago
JSP
Hi,

I hava 1 error in accessing database using javabean in jsp(jsp custom actions).The error like this

javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt

my source code is given below.Anybody help me??


package SQLBean;
import java.sql.*;
import java.io.*;
public class DbBean implements java.io.Serializable{
private String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
private Connection dbCon;
public DbBean(){
super();
}

public boolean connect() throws ClassNotFoundException,SQLException{
Class.forName(dbDriver);
dbCon = DriverManager.getConnection("jdbc dbc:mybean","","");
return true;
}
public void close() throws SQLException{
dbCon.close();
}
public ResultSet execSQL(String sql) throws SQLException{
Statement s = dbCon.createStatement();
ResultSet r = s.executeQuery(sql);
return (r == null) ? null : r;
}
public int updateSQL(String sql) throws SQLException{
Statement s = dbCon.createStatement();
int r = s.executeUpdate(sql);
return (r == 0) ? 0 : r;
}
}


<HTML>
<HEAD><TITLE>DataBase Search</TITLE></HEAD>
<BODY>

<%@ page language="Java" import="java.sql.*" %>
<%@ page import="SQLBean.*"%>

<jsp:useBean id="db" scope="application" class="SQLBean.DbBean" />

<jsp:setProperty name="db" property="*" />

<center>
<h2> Results from </h2>
<hr>
<br><br>
<table>

<%
db.connect();
ResultSet rs = db.execSQL("select * from employ");
int i = db.updateSQL("UPDATE employ set fname = 'raji' where empno='000010'");
out.println(i);

while(rs.next()) {
%>
<%= rs.getString("empno") %>
<BR>
<%
}
%>
<BR>
<%
db.close();
%>
Done
</table>
</body>
</HTML>

Anyone help me??
Thanx in advance....
Hi,

I have an error, during accessing a datbase using jsp:useBean from jsp.Urgent i need this one
my source code is



DbBean.java

package SQLBean;
import java.sql.*;
import java.io.*;

public class DbBean implements java.io.Serializable{

private String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
private Connection dbCon;

public DbBean(){
super();
}

public boolean connect() throws ClassNotFoundException,SQLException{
Class.forName(dbDriver);
dbCon = DriverManager.getConnection("jdbc dbc:mybean","","");
return true;
}



public void close() throws SQLException{
dbCon.close();
}

public ResultSet execSQL(String sql) throws SQLException{

Statement s = dbCon.createStatement();
ResultSet r = s.executeQuery(sql);
return (r == null) ? null : r;
}

public int updateSQL(String sql) throws SQLException{
Statement s = dbCon.createStatement();
int r = s.executeUpdate(sql);
return (r == 0) ? 0 : r;
}

}


database.jsp
<HTML>
<HEAD><TITLE>DataBase Search</TITLE></HEAD>
<BODY>

<%@ page language="Java" import="java.sql.*" %>

<jsp:useBean id="db" scope="application" class="SQLBean.DbBean" />

<jsp:setProperty name="db" property="*" />

<center>
<h2> Results from </h2>
<hr>
<br><br>
<table>

<%
db.connect();


ResultSet rs = db.execSQL("select * from employ");
int i = db.updateSQL("UPDATE employ set fname = 'hello world' where empno='000010'");
out.println(i);



%>

<%
while(rs.next()) {
%>
<%= rs.getString("empno") %>
<BR>
<%
}
%>
<BR>
<%

db.close();

%>

Done

</table>

</body>

</HTML>

The error like this

org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
error: Invalid class file format in C:\Program Files\Apache Tomcat 4.0\webapps\muthu\WEB-INF\classes\SQLBean\DbBean.class. The major.minor version '49.0' is too recent for this tool to understand.


An error occurred at line: 8 in the jsp file: /database.jsp

Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:70: Class SQLBean.DbBean not found.
SQLBean.DbBean db = null;
^


An error occurred at line: 8 in the jsp file: /database.jsp

Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:73: Class SQLBean.DbBean not found.
db= (SQLBean.DbBean)
^


An error occurred at line: 8 in the jsp file: /database.jsp

Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:78: Class SQLBean.DbBean not found.
db = (SQLBean.DbBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "SQLBean.DbBean");
^
4 errors, 1 warning

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:285)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:552)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:177)

Anybody help me?
Thanx in advance
14 years ago
JSP
Hi,

I have an error, during accessing a datbase using jsp:useBean from jsp.Urgent i need this one


my source code ispackage SQLBean;

DbBean.java

import java.sql.*;
import java.io.*;

public class DbBean implements java.io.Serializable{

private String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
private Connection dbCon;

public DbBean(){
super();
}

public boolean connect() throws ClassNotFoundException,SQLException{
Class.forName(dbDriver);
dbCon = DriverManager.getConnection("jdbc dbc:mybean","","");
return true;
}



public void close() throws SQLException{
dbCon.close();
}

public ResultSet execSQL(String sql) throws SQLException{

Statement s = dbCon.createStatement();
ResultSet r = s.executeQuery(sql);
return (r == null) ? null : r;
}

public int updateSQL(String sql) throws SQLException{
Statement s = dbCon.createStatement();
int r = s.executeUpdate(sql);
return (r == 0) ? 0 : r;
}

}


database.jsp
<HTML>
<HEAD><TITLE>DataBase Search</TITLE></HEAD>
<BODY>

<%@ page language="Java" import="java.sql.*" %>

<jsp:useBean id="db" scope="application" class="SQLBean.DbBean" />

<jsp:setProperty name="db" property="*" />

<center>
<h2> Results from </h2>
<hr>
<br><br>
<table>

<%
db.connect();


ResultSet rs = db.execSQL("select * from employ");
int i = db.updateSQL("UPDATE employ set fname = 'hello world' where empno='000010'");
out.println(i);



%>

<%
while(rs.next()) {
%>
<%= rs.getString("empno") %>
<BR>
<%
}
%>
<BR>
<%

db.close();

%>

Done

</table>

</body>

</HTML>


The error like this

org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
error: Invalid class file format in C:\Program Files\Apache Tomcat 4.0\webapps\muthu\WEB-INF\classes\SQLBean\DbBean.class. The major.minor version '49.0' is too recent for this tool to understand.


An error occurred at line: 7 in the jsp file: /database.jsp

Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:65: Class SQLBean.DbBean not found.
SQLBean.DbBean db = null;
^


An error occurred at line: 7 in the jsp file: /database.jsp

Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:68: Class SQLBean.DbBean not found.
db= (SQLBean.DbBean)
^


An error occurred at line: 7 in the jsp file: /database.jsp

Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:73: Class SQLBean.DbBean not found.
db = (SQLBean.DbBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "SQLBean.DbBean");
^
4 errors, 1 warning

Anybody help me?
Thanx in advance
14 years ago
JSP
// my html code that calls the Javabean stored in the following path : "http//localhost:8080/vennila/Beans/bean.jsp"
<html>

<body>
<jsp:useBean id="a" class="sun.bean" scope="session"/>
<jsp:setProperty name="a" property="*"/>
<%=a.getName()%>
<%=a.getName2()%>
</body>

</html>


// my input page that calls the <html>

<head>

<title>New Page 1</title>
</head>

<body>

<form method="POST" action="http://localhost:8080/vennila/Beans/bean.jsp">;

<p><input type="text" name="name" size="20"></p>
<p><input type="text" name="name2" size="20"></p>
<p><input type="submit" value="Submit" name="B1"></p>
</form>

</body>

</html>

// my java bean stored in the following path : C:\Program Files\Apache Tomcat 4.0\webapps\vennila\WEB-INF\classes

package sun;
public class bean implements java.io.Serializable
{
private String name;
private String name2;

public bean()
{
}

public void setName(String name1)
{
name=name1;
}
public String getName()
{
return name;
}

public void setName2(String name3)
{
name2=name3;
}
public String getName2()
{
return name2;
}
}

while compiling the bean file i haven't got any error but when executing the jsp file i am getting the following error,

org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
error: Invalid class file format in C:\Program Files\Apache Tomcat 4.0\webapps\vennila\WEB-INF\classes\sun\bean.class. The major.minor version '49.0' is too recent for this tool to understand.


An error occurred at line: 4 in the jsp file: /Beans/bean.jsp

Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\vennila\Beans\bean$jsp.java:60: Class sun.bean not found.
sun.bean a = null;
^

when i execute the same code in my neighbours system its working. kindly let me know what could be the reason in my system or is it in my program.
14 years ago
JSP
I am calling an javabean named sun.beantest in JSP. On execution i am getting the following error :

org.apache.jasper.compiler.ParseException: /test1.jsp(2,41) Attribute sun.beantest has no value


If anyone help me i will be very thankful to them.pls........
14 years ago
JSP
Kindly suggest me a good reference book for Javabean concepts in JSP. Help me
14 years ago
JSP
// My JSP coding. This is stored in the following path ]http://localhost:8080/vennila/test.jsp
<HTML>
<HEAD><TITLE>DataBase Search</TITLE></HEAD>
<BODY>

<%@ page language="Java" import="java.sql.*" %>
<jsp:useBean id="db" scope="application" class="SQLBean.DbBean"/>
<jsp:setProperty name="db" property="*" />

<%!
ResultSet rs = null ;
ResultSetMetaData rsmd = null ;
int numColumns ;
int i;
%>
<center>
<h2> Results from </h2>
<hr>
<br><br>
<table>
<%
db.connect();
rs = db.execSQL("select * from emp1");
i = db.updateSQL("UPDATE emp1 set fname = 'hello world' where
empid=101");
out.println(i);

rsmd = rs.getMetaData();
numColumns = rsmd.getColumnCount();
for(int column=1; column <= numColumns; column++)
{
out.println(rsmd.getColumnName(column));
}
%>

<%
while(rs.next())
{
%>
<%= rs.getString("empid") %>
<BR>
<%
}
%>
<BR>
<%
db.close();
%>
Done
</table>
</body>
</HTML>



//My Java Package Coding. It is compiled and stored in the following path: C:\Program Files\Apache Tomcat 4.0\webapps\vennila\WEB-INF\classes\
package SQLBean;

import java.sql.*;
import java.io.*;


public class DbBean {

String dbURL = "sun.jdbc.odbc.JdbcOdbcDriver";
String dbDriver = "'jdbc dbc:emp','',''";
private Connection dbCon;

public DbBean(){
super();
}

public boolean connect() throws ClassNotFoundException,SQLException{
Class.forName(dbDriver);
dbCon = DriverManager.getConnection(dbURL);
return true;
}



public void close() throws SQLException{
dbCon.close();
}

public ResultSet execSQL(String sql) throws SQLException{

Statement s = dbCon.createStatement();
ResultSet r = s.executeQuery(sql);
return (r == null) ? null : r;
}



public int updateSQL(String sql) throws SQLException{
Statement s = dbCon.createStatement();
int r = s.executeUpdate(sql);
return (r == 0) ? 0 : r;
}

}

----------------- xxxx-------------------------

When i run the jsp in internet explorer its giving me the following error :

C:\Program Files\Apache Tomcat 4.0 work\localhost\vennila\test$jsp.java:72: Class SQLBean.DbBean not found.
SQLBean.DbBean db = null;
^


My Java file is stored in the following path : C:\Program Files\Apache Tomcat 4.0\webapps\vennila\WEB-INF\classes

My Class file is stored in the following path :
C:\Program Files\Apache Tomcat 4.0\webapps\vennila\WEB-INF\classes\SQLBean


I am breaking my head towards this problem for the past 4 days. I am new to Bean concept. kindly help me to solve this problem.
14 years ago
JSP
// My JSP coding. This is stored in the following path ]http://localhost:8080/vennila/test.jsp

<HTML>
<HEAD><TITLE>DataBase Search</TITLE></HEAD>
<BODY>

<%@ page language="Java" import="java.sql.*" %>
<jsp:useBean id="db" scope="application" class="SQLBean.DbBean"/>
<jsp:setProperty name="db" property="*" />

<%!
ResultSet rs = null ;
ResultSetMetaData rsmd = null ;
int numColumns ;
int i;
%>
<center>
<h2> Results from </h2>
<hr>
<br><br>
<table>
<%
db.connect();
rs = db.execSQL("select * from emp1");
i = db.updateSQL("UPDATE emp1 set fname = 'hello world' where
empid=101");
out.println(i);

rsmd = rs.getMetaData();
numColumns = rsmd.getColumnCount();
for(int column=1; column <= numColumns; column++)
{
out.println(rsmd.getColumnName(column));
}
%>

<%
while(rs.next())
{
%>
<%= rs.getString("empid") %>
<BR>
<%
}
%>
<BR>
<%
db.close();
%>
Done
</table>
</body>
</HTML>



//My Java Package Coding. It is compiled and stored in the following path: C:\Program Files\Apache Tomcat 4.0\webapps\vennila\WEB-INF\classes\

package SQLBean;

import java.sql.*;
import java.io.*;


public class DbBean {

String dbURL = "sun.jdbc.odbc.JdbcOdbcDriver";
String dbDriver = "'jdbc dbc:emp','',''";
private Connection dbCon;

public DbBean(){
super();
}

public boolean connect() throws ClassNotFoundException,SQLException{
Class.forName(dbDriver);
dbCon = DriverManager.getConnection(dbURL);
return true;
}



public void close() throws SQLException{
dbCon.close();
}

public ResultSet execSQL(String sql) throws SQLException{

Statement s = dbCon.createStatement();
ResultSet r = s.executeQuery(sql);
return (r == null) ? null : r;
}



public int updateSQL(String sql) throws SQLException{
Statement s = dbCon.createStatement();
int r = s.executeUpdate(sql);
return (r == 0) ? 0 : r;
}

}

----------------- xxxx-------------------------

When i run the jsp in internet explorer its giving me the following error :

C:\Program Files\Apache Tomcat 4.0 work\localhost\vennila\test$jsp.java:72: Class SQLBean.DbBean not found.
SQLBean.DbBean db = null;
^


My Java file is stored in the following path : C:\Program Files\Apache Tomcat 4.0\webapps\vennila\WEB-INF\classes

My Class file is stored in the following path :
C:\Program Files\Apache Tomcat 4.0\webapps\vennila\WEB-INF\classes\SQLBean


I am breaking my head towards this problem for the past 4 days. I am new to Bean concept. kindly help me to solve this problem.
14 years ago
JSP
// My JSP coding. This is stored in the following path ]http://localhost:8080/vennila/test.jsp
<HTML>
<HEAD><TITLE>DataBase Search</TITLE></HEAD>
<BODY>

<%@ page language="Java" import="java.sql.*" %>
<jsp:useBean id="db" scope="application" class="SQLBean.DbBean"/>
<jsp:setProperty name="db" property="*" />

<%!
ResultSet rs = null ;
ResultSetMetaData rsmd = null ;
int numColumns ;
int i;
%>
<center>
<h2> Results from </h2>
<hr>
<br><br>
<table>
<%
db.connect();
rs = db.execSQL("select * from emp1");
i = db.updateSQL("UPDATE emp1 set fname = 'hello world' where
empid=101");
out.println(i);

rsmd = rs.getMetaData();
numColumns = rsmd.getColumnCount();
for(int column=1; column <= numColumns; column++)
{
out.println(rsmd.getColumnName(column));
}
%>

<%
while(rs.next())
{
%>
<%= rs.getString("empid") %>
<BR>
<%
}
%>
<BR>
<%
db.close();
%>
Done
</table>
</body>
</HTML>



//My Java Package Coding. It is compiled and stored in the following path :
C:\Program Files\Apache Tomcat 4.0\webapps\vennila\WEB-INF\classes\



package SQLBean;

import java.sql.*;
import java.io.*;


public class DbBean {

String dbURL = "sun.jdbc.odbc.JdbcOdbcDriver";
String dbDriver = "'jdbc dbc:emp','',''";
private Connection dbCon;

public DbBean(){
super();
}

public boolean connect() throws ClassNotFoundException,SQLException{
Class.forName(dbDriver);
dbCon = DriverManager.getConnection(dbURL);
return true;
}



public void close() throws SQLException{
dbCon.close();
}

public ResultSet execSQL(String sql) throws SQLException{

Statement s = dbCon.createStatement();
ResultSet r = s.executeQuery(sql);
return (r == null) ? null : r;
}



public int updateSQL(String sql) throws SQLException{
Statement s = dbCon.createStatement();
int r = s.executeUpdate(sql);
return (r == 0) ? 0 : r;
}

}

----------------- xxxx-------------------------

When i run the jsp in internet explorer its giving me the following error :

C:\Program Files\Apache Tomcat 4.0 work\localhost\vennila\test$jsp.java:72: Class SQLBean.DbBean not found.
SQLBean.DbBean db = null;
^



I am breaking my head towards this problem for the past 4 days. I am new to Bean concept. kindly help me to solve this problem.

[ April 16, 2006: Message edited by: raji navaneethan ]
[ April 16, 2006: Message edited by: raji navaneethan ]
14 years ago
JSP
In Java bean, I have 2 methods one for executing select statement and another one is executing update statement.When i am compiling the javabean i haven't any error.When i calling javabean with jsp(using jsp:usebean...).I have an error like packagename.classname not found
can u help me???

Thank you
14 years ago
JSP
Hi,


Using enter key only,How to go to the next page in submit button(without clicking that button(onclick) , using the tabkey).Anyone can u help me.....



Thank you
Hi,

I haven't any idea about servlet chaining. anyone send small sample for servlet chaining.


Thank you
14 years ago