*
The moose likes Servlets and the fly likes help! strange error in servlet running Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "help! strange error in servlet running " Watch "help! strange error in servlet running " New topic
Author

help! strange error in servlet running

Victor Lam
Greenhorn

Joined: Mar 17, 2004
Posts: 2
My servlet code is like this:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import java.text.*;
public class JDBC4Servlet extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{ response.setContentType("text/html");
PrintWriter out = new PrintWriter(response.getOutputStream());
out.println("<HTML>");
out.println("<HEAD><TITLE>Table</TITLE></HEAD>");
out.println("<BODY>");
try{
//System.setProperty("jdbc.drivers", "com.mysql.jdbc.Driver");
Class.forName("oracle.jdbc.driver.OracleDriver");
out.println("-1");
out.flush();
out.println("0");
out.flush();
Connection con =
DriverManager.getConnection("jdbc racle:thin:@kgdev01:1521:testdb","sysadmin","kinetix");
// this line has problem
out.println("1");
out.flush();
Statement stmt = con.createStatement();
out.println("2");
.................
The file succeds to compile and then i put the servlet class file into
the websphere application server directory.
I open the browser and then test the servlet.
The error output is:
-1 0 java.lang.ArrayIndexOutOfBoundsException: 7
But if I set the incorrect username as the parameter of the
getconnection
The servlet can suceed to detect invalid user log in. The output is :
-1 0 java.sql.SQLException: ORA-01017: invalid username/password; logon
denied
This mean that the connection setting should be correct.
Anyone know how to solve this problem.
Thx for reply.
Victor Lam
Greenhorn

Joined: Mar 17, 2004
Posts: 2
this version is more correct
My servlet code is like this:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import java.text.*;
public class JDBC4Servlet extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{ response.setContentType("text/html");
PrintWriter out = new PrintWriter(response.getOutputStream());
out.println("<HTML>");
out.println("<HEAD><TITLE>Table</TITLE></HEAD>");
out.println("<BODY>");
try{
//System.setProperty("jdbc.drivers", "com.mysql.jdbc.Driver");
Class.forName("oracle.jdbc.driver.OracleDriver");
out.println("-1");
out.flush();
out.println("0");
out.flush();
Connection con =
DriverManager.getConnection("jdbc. oracle:thin:@kgdev01:1521:testdb","sysadmin","kinetix");
// this line has problem
out.println("1");
out.flush();
Statement stmt = con.createStatement();
out.println("2");
.................
The file succeds to compile and then i put the servlet class file into
the websphere application server directory.
I open the browser and then test the servlet.
The error output is:
-1 0 java.lang.ArrayIndexOutOfBoundsException: 7
But if I set the incorrect username as the parameter of the
getconnection
The servlet can suceed to detect invalid user log in. The output is :
-1 0 java.sql.SQLException: ORA-01017: invalid username/password; logon
denied
This mean that the connection setting should be correct.
Anyone know how to solve this problem.
Thx for reply.
Chandra Bairi
Ranch Hand

Joined: Sep 12, 2003
Posts: 152
If you are entering the wrong password then you would surely not get the connection and hence the error.
but for the arrayindexoutofboundexception you should give the complete code. because i am unable to under stand the problem seeing only that part of the code. kindly present the complete code.
regards,
shekar.


Thanks,
Shekar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help! strange error in servlet running
 
Similar Threads
Servlet becomming slow
Servlet becomming slow
Connection Pooling
Problem with JSPs in web application
Is SSI supported on tomcat