servlet problem
serifu Nov 28, 2001 1:07 PMPlease take a look at this code:
..........
public class TreeServlet extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
..........
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.close();
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.print("Romania Duty Free");
out.print("");
long time1 = System.currentTimeMillis();
// connecting to database
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
String value = null;
String newvalue = null,Target = "",Link = "";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:conection","username","password");
...................
rs = stmt.executeQuery("select COD,DENUMIRE,TIP from GCS where tip='G' and substring(cod,1,2) != '10' and substring(cod,1,2) != '20'");
// displaying records
while( rs.next() ) {
out.print("");
//out.print(rs.getString("cod"));
//out.print("\t");
String denumire = rs.getString("DENUMIRE");
//this line generate erorr 500
//javax.servlet.ServletException: Servlet Could not display records.
//on tomcat 3.2.3
.............
..............
//the select statement is made on sql server database and DENUMIRE is NVARCHAR type
//if i print out rs.getString("DENUMIRE") everything is ok by i can't use this for comparation between string...Somebody can help me?Thank's in advance!!
} catch (SQLException e) {
throw new
ServletException("Servlet Could not display records.", e);
} catch (ClassNotFoundException e) {
throw new
ServletException("JDBC Driver not found.", e);
} finally {
try {
if(rs != null) {
rs.close();
rs = null;
}
if(stmt != null) {
stmt.close();
stmt = null;
}
if(con != null) {
con.close();
con = null;
}
} catch (SQLException e) {}
}
// debugging info
}.............