How to… MySql and JSP

Posted on February 24, 2006

A while ago, I had a problem connecting to mysql using jsp. But after several times of following the steps, I’ve finally figured it out.


Things you need to get for it to work:
1. J2sdk (I’m using 1.4.2)
2. Tomcat (4.1.31)
3. MySql (I don’t know what version im using)
4. MySql connector/j (mine is mysql-connector-java-3.0.17-ga-bin.jar, and i recommend it)

I assume you already know how to install j2sdk, tomcat, and mysql, and You’ve already set it in eviromental settings. If not, google it and go back here. :)

Once you’ve setup everything, extract your mysql connector and place it in j2sdkfolder\jre\ext
(here’s how it looks like: D:\project\j2sdk1.4.2_06\jre\lib\ext). I hope you get it, coz I don’t. hehe

If everything looks ok and you followed it carefully, restart your pc.

Run tomcat server and mysql. Create a database or if you have an existing database then that’s much better. I won’t explain everything here, ok? Copy this jsp code and save it under tomcat_folder\webapps\root\FILENAME.JSP

download it here

Open a web browser and type http://localhost:8080/filename.jsp. If it doesn’t work, try again and make sure you follow the steps correctly. O yah, the page should display whatever is in your query.

Remember to change DATABASENAMEHERE to the database name that you want to access, USERHERE to your username, YOURPASSWORHERE to your password, YOURTABLE to table name in that database, FIELDHERE to a field in that table…

Thanks, I hope It will work coz it worked for me.

Comments

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)

Website


Comments