aspose file tools*
The moose likes JSP and the fly likes JSP x MSSQL SERVER? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP x MSSQL SERVER? " Watch "JSP x MSSQL SERVER? " New topic
Author

JSP x MSSQL SERVER?

wiwil
Greenhorn

Joined: May 09, 2002
Posts: 1
any one can help-me?
<%@ page import="java.sql. *" %>
<jsp:useBean id="item" class="ItemBean">
<%
private Connection conexao = null;
private Statement declaracao = null;
private ResultSet resultado = null;
private String pesquisa = null;
private String atualiza = null;
ItemBean item = new ItemBean ();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String query = "SELECT Pcp_Codigo FROM PC WHERE Pcp_Codigo in ('10000','10001')";
conexao = DriverManager.getConnection("jdbc dbc:SERVIDOR02:1433?database=NomedoBanco","NomedaTabela","PSW");
declaracao = conexao.createStatement();
resultado = declaracao.executeQuery(query);
if (resultado.next()){
item.query(resultado.getInteger("Pcp_Codigo");
}
conexao.close();
}
catch (ClassNotFoundException e){
System.err.println ("Nao funfou driver");
}
catch (SQLException e){
System.err.println ("Nao funfou banco");
}
finally {
try{ if (conexao != null) conexao.close() ;}
catch (SQLException e) { }
}

%>
</jsp:useBean>
<HTML><HEAD><TITLE> New Document </TITLE></HEAD>
<BODY BGCOLOR="#FFFFFF">
<table><tr><td>a</td><td>
<jsp:getProperty name="item" property="id"/>
</td></tr></table>
</BODY>
</HTML>

ERROR ------------>

description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: ItemBean
root cause
java.lang.ClassNotFoundException: ItemBean
Brian Glodde
Ranch Hand

Joined: Jun 27, 2001
Posts: 171
Your bean is not found! Is it in a package? If so you'll need to prefix the tag accordingly.
You'll also need to change your name, JavaRanch
has a naming convention, described at http://www.javaranch.com/name.jsp
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Thanks, Brian.
"wiwil"
Please change your "Publicly Displayed Name" by modifying your Profile after reviewing the guidelines at http://www.javaranch.com/name.jsp
Assuming you will do that, I am answering your qstn. Please cooperate.
<jsp:useBean id="item" class="ItemBean">

It is not a good practice to put beans without a package. If you do this then the App server will look for the bean in the same package that your generated Servlet code is. Obviously, that fails.
Also, you are NOT using the useBean tag correctly.
<jsp:useBean ...>
[ code ]
</jsp:useBean>.


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JSP x MSSQL SERVER?