Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP x MSSQL SERVER?

 
wiwil
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic