Skip navigation links

MySQL Forums :: Connector/JDBC and Java :: Connection to mysql using jsp


Advanced Search

Connection to mysql using jsp
Posted by: arun chanumalla ()
Date: April 04, 2005 10:50AM

hi,

i came across a strange problem.
After installing mysql-3.23.58.i tried to test the JDBC connection to mysql with the following program.

it worked fine and gave me all the expected results.
after few days when iam trying to run the same program,i get page cannot be displayed error after about 15 min after the page was loaded.

looks like its trying to process the jsp file and failed.
all other jsp pages without database connections are working fine.

here goes my program.

*********************** Start***************************


<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%! Connection con=null; %>
<%! Statement st= null; %>
<%! ResultSet rs= null; %>


<html>
<head><title>This is a Jdbc Example</title></head>
<body>

<%
out.println("Arun K Chanumalla");


try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
}catch(ClassNotFoundException ce){out.println(ce);}

try{
con = DriverManager.getConnection("jdbc:mysql://localhost/weather","chanumaa", "arcims");
st = con.createStatement();
rs = st.executeQuery("SELECT name, age FROM arun");
while(rs.next()) {

String name = rs.getString(1);
int age = rs.getInt(2);
out.println(name + " " +age+"<br>");

} // end of whilee
rs.close();
st.close();
con.close();

}catch(SQLException exception){
out.println("<!--");
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
exception.printStackTrace(pw);
out.print(sw);
sw.close();
pw.close();
out.println("-->");

}



%>
</body>
</html>

*************************** end**************************


i tried to run the same program by saving it with .java extension by making all necessary changes, the program then worked fine and gave the expected results.

the bottomline is iam using the same database,table,driver for both jsp,java programs.
the .java is working and not the .jsp

i have no clue y..??
any of you database techies may want to throw some suggestions here please..??

Regards
Arun

Options: ReplyQuote


Subject Written By Posted
Connection to mysql using jsp arun chanumalla 04/04/2005 10:50AM
Re: Connection to mysql using jsp Sudhir Movva 04/05/2005 01:36PM
Re: Connection to mysql using jsp Megha Bhagat 04/18/2005 03:30AM
Re: Connection to mysql using jsp yenne jagadeesh 11/15/2006 04:20AM
Re: Connection to mysql using jsp Bill Karwin 11/15/2006 10:57AM
connection to mysql using jsp junia phiong 11/27/2005 05:27AM
Connection to mysql using jsp bindu priyadarshini 09/24/2006 09:39AM
Re: Connection to mysql using jsp Bill Karwin 09/24/2006 10:26AM
Connection to mysql using jsp uma maheswari 12/27/2007 11:53PM
Re: Connection to mysql using jsp kuna Ram 12/31/2007 09:54PM
Re: Connection to mysql using jsp sukasom chaiyakul 04/06/2005 05:16AM
Re: Connection to mysql using jsp Ashish Patil 01/21/2006 07:59AM
Re: Connection to mysql using jsp Ashish Patil 01/21/2006 07:42AM
Re: Connection to mysql using jsp Vetri Selvan 02/15/2006 12:12AM
Re: Connection to mysql using jsp Arun Kumar 02/19/2006 11:57PM
Connection to mysql using jsp/jdbc Arun Kumar 02/20/2006 01:46AM
Re: Connection to mysql using jsp/jdbc raj kris 12/14/2007 01:11AM
Connection to mysql using jsp/jdbc Anitha 05/16/2006 05:58AM
Re: Connection to mysql using jsp Antonel Pazargic 02/20/2006 12:20AM
Re: Connection to mysql using jsp mitesh bhimjiyaani 05/17/2006 07:26AM
Re: Connection to mysql using jsp yenne jagadeesh 11/15/2006 04:15AM
Re: Connection to mysql using jsp labhshree kodhe 06/05/2006 12:41AM
Re: Connection to mysql using jsp sourav mukherjee 08/03/2007 06:24AM
Re: Connection to mysql using jsp sekhar babu patnam 08/08/2007 12:44AM
create System DSN in jsp? b g 06/09/2009 04:43AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.