Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Jsp + My Sql


Published on

A simple walthrough to connect JSP with MySql Database.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

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 : • 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.