Sunday, January 24, 2010

Mysql Connectivity with JSP

Download connector / j  Jar file and copy in to Apache Software Foundation\Apache Tomcat 6.0.14\lib folder and restart tomcat server.

Now creat a connection.jsp file to test the connectivity..

<%@ page language="java" import="java.sql.*" %>
<%
    Connection conn = null;
    Statement st =null;
    ResultSet rst = null;
    try {
                  Class.forName("com.mysql.jdbc.Driver").newInstance();
                  conn = DriverManager.getConnection("jdbc:mysql:///databsename","mysql-username", "mysql-password");
                  if(!conn.isClosed())
                    out.println("Successfully connected to " +"MySQL server using TCP/IP...\n");
        } catch (SQLException ex) {
            // handle any errors
            out.println("SQLException: " + ex.getMessage());
            out.println("SQLState: " + ex.getSQLState());
            out.println("VendorError: " + ex.getErrorCode());
        }
  %>

Saturday, July 14, 2007

Welcome to new world

Hi,
To all,
I am imteyaz from delhi... This is my first weblog............ I am waiting for others valuable comments.......and recommendations........