how we create dsn in JSP with backend MySQL?


Web tier: servlets, JSP, Web frameworks: how we create dsn in JSP with backend MySQL?

  1. how we create dsn in JSP with backend MySQL? (3 messages)

    hello every body.I am from delhi-india. I am developing a portal in JSP and backend as MySQL. At one point I am struck very seriously so need very urgent help from you as seen your message on Can you tell me how how we create DSN in it and what is the syntex?An early help will be highly appreciated.with thanks & regards.
  2. Hi frnd here i am attaching u a sample page which uses dsn connection for jsp page

    <%@ page language="java" import="*, java.sql.*" %>

    <form name="frm1">

    //employee the dsn name which connects to a database.

         Connection con = DriverManager.getConnection("jdbc:odbc:employee");
         Statement stmt = con.createStatement();
         Statement stmt1 = con.createStatement();
         stmt1.executeUpdate("insert into employee values(3,'khan')");
         ResultSet rs = stmt.executeQuery("select * from employee");


    <TABLE border=1>
      <TD> &nbsp
         <SELECT NAME="select">
         <% while(
       <% } %>
      <TD align="right">
         <SELECT NAME="SEL1">
         <OPTION> NEW </OPTION>
         <% while(

    <% } %>



    // for(int i = 0 ; i<100; i++)
    // stmt1.executeUpdate("insert into employee (ename) values('"+i+" Record')");


       catch(Exception e)
         out.println("message exception" + e.getMessage());


  3. Hi.

    Use driver
    Protocol = jdbc:mysql:///Database_name
    Use this type 4 driver from
    The documentation comes along with this driver.
    U need to add this driver to the system classpath

    Vijay Khanna
  4. You can get the MySQL driver here:

    You can either add the jar to your classpath or put it in the lib directory of your jsp container.

    You can also use JNDI to lookup the driver by:

    InitialContext ic = new InitialContext();
    DataSource ds = (DataSource) ic.lookup(JNDI name of driver);
    Connection connnection = ds.getConnection();

    You should be able to setup the JNDI name for the driver in your container.