How to setup a MySQL database connection via JNDI?

Hello, I am newbie in JSP, I read some books and know there are several methods of connecting to MySQL db, and I would like to know how to setup one via JNDI look up.

I dont know the concept thoroughly, I just know I should write in a java file, xml and install some jar files in suitable folder?

Can anyone have some basic suggestion or tutorial which can help?

Thx..^^

[395 byte] By [roamera] at [2007-11-26 15:06:18]
# 1
You can find installation instructions by what you want to install. I'm assuming you want to install JDK, Tomcat application server, desired JAR files ? Also you may need to learn the basics of Java, JSP and a little bit of Tomcat.
appy77a at 2007-7-8 8:56:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

in my web.xml file,

--

...

<database>

<jndi-name>jdbc/mysql</jndi-name>

<driver>

<type>com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource</type>

<url>jdbc:mysql://localhost:3306/roamer</url>

<user>user</user>

<password>password</password>

</driver>

</database>

...

--

In my web.xml file i added these lines, I would like to ask how can I setup a test connection via JDNI look in my test.jsp page?

thx ^^

roamera at 2007-7-8 8:56:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

I'm sorry I don't know much about JNDI but, you could write a JavaBean that has all the database connection code, and then you can invoke this JavaBean from the JSP page with jsp:useBean

Although, I don't think the above method is a good practice, but that's all I know for now.

I can however point you to the right forums, I think the forum members over there will be better able to help you since the topic is more closely related to those forums (incase no one else replies here).

JNDI Forum

http://forum.java.sun.com/forum.jspa?forumID=51&start=0

http://wiki.java.net/bin/view/Javapedia/JNDI

Java Database Connectivity (JDBC)

http://forum.java.sun.com/forum.jspa?forumID=48

appy77a at 2007-7-8 8:56:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...