Jsp + My Sql

908
-1

Published on

A simple walthrough to connect JSP with MySql Database.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
908
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
55
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Jsp + My Sql

  1. 1. JSP to create usable apps. A fun way + MySQL
  2. 2. THE BASICS • What is JSP? • What is JDBC? • What is ODBC?
  3. 3. What Exactly is JDBC? • JDBC is an API for the Java programming language that defines how a client may access a database. It provides methods for querying and updating data in a database. JDBC is oriented towards relational databases. Servlet JDBC ODBC DB
  4. 4. How do we do that???
  5. 5. Loading the JDBC Driver • We should have the Driver!!! • MySQL Connector/J - version 2 used for this tutorial Download Link : http://dev.mysql.com/downloads/connector/j/ • Copy it to the “lib” folder in the server.
  6. 6. Loading the JDBC Driver • To load the driver you only need to load the appropriate class. • Syntax : Class.forName(“fully qualified class name”) • For MySQL : Class.forName(“com.mysql.jdbc.driver”)
  7. 7. Defining the connection URL • Driver is ready to go..But where??? • Define a connection URL which specifies the SERVER & the Database needed • “jdbc:mysql://localhost:3306/db_name”
  8. 8. Establishing the connection • The actual network connection!! • Connection conn=DriverManager.getConnection(“Connection URL”,”user”,”pass”);
  9. 9. Creating the statement Object • Statement stmt = conn.createStatement(); • Statement Object sends queries and commands to the database.
  10. 10. HOW EXACTLY DOES ALL THIS WORK??? LIVE DEMO

×