This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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


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
 
GeeCON Prague 2014
 
subject: JSP x MSSQL SERVER?