Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-17-2006, 02:43 AM   #1
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Rep: Reputation: 30
Configuring JSP and MySQL

It is my first day working with JSP so I am not quite familiar with it. I am going to deploy a small database program using JSP on tomcat. I have downloaded MySQL Connector/J and extracted it on my hard disk and then copied the jar file to following directory like this:

cp softs/mysql-connector-java-5.0.4/mysql-connector-java-5.0.4-bin.jar /usr/local/tomcat/webapps/ROOT/WEB-INF/lib/
I have a database called employee and a table inside it called employees in /var/lib/mysql/ directory
Here is my JSP file:

<HEAD><TITLE>Employee List</TITLE></HEAD>
<%@ page import="java.sql.*" %>
<TABLE BORDER=1 width="75%">
<TR><TH>Last Name</TH><TH>First Name</TH></TR>
Connection conn = null;
Statement st = null;
ResultSet rs = null;
try {
	conn = DriverManager.getConnection("jdbc:mysql://localhost/employee?user=root;password=esteghlal");
	st = conn.createStatement();
	rs = st.executeQuery("select * from employees");
	while( {
	<TR><TD><%= rs.getString("lname_txt") %></TD>
	<TD><%= rs.getString("fname_txt") %></TD></TR>
} catch (Exception ex) {
Ooops, something bad happened:
} finally {
if (rs != null) rs.close();
if (st != null) st.close();
if (conn != null) conn.close();
But at the end I am not able to see the list.

I would be glad if someone helps me.

Old 12-17-2006, 02:46 AM   #2
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Original Poster
Rep: Reputation: 30
Sorry for wasting your time. I figured out where the problem is.
I should use & instead of ; in the following line:
conn = DriverManager.getConnection("jdbc:mysql://localhost/employee?user=root&password=esteghlal");


jsp, mysql

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
JSP and MySQL - unable to load JDBC driver jun_tuko Programming 2 09-05-2006 11:02 AM
connectivity of jsp file with mysql in fedora core 4 anshu.rahul Fedora 0 05-03-2006 07:37 AM
Need basic code to connect to MySQL using JSP / JAVA jun_tuko Programming 4 01-16-2006 03:15 AM
[ JSP/JAVA ] MySQL connection fails White R4bbit Programming 4 04-27-2005 08:31 AM
an error occur when jsp connect to mysql? shitian8848 Programming 2 06-04-2004 02:08 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:05 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration