MySQL + Tomcat JSP Test Script

Filed in jsp 0 comments

Coding kat atas tu adalah untuk test connection diantara MySql + Tomcat JSP. so kalau korang pening tibe2 error kluar, tapi tengok coding semua dah betul. tapi tak tau kenapa application with db korang tu tak leh nak run. ada keluar error. so try guna coding kat atas ni check samada database dan tomcat korang bleh connect tak..

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

02.<html>
03.<head>
04.<title>Obtaining a Connection </title>
05.</head>
06.<body>
07.<%
08.Connection conn=null;
09.ResultSet result=null;
10.Statement stmt=null;
11.ResultSetMetaData rsmd=null;
12.try
13.{
14.Class c=Class.forName("com.mysql.jdbc.Driver");
15.}
16.catch(Exception e)
17.{
18.out.write("Error!!!!!!" + e);
19.}
20.try
21.{
22.conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/databasename","username","password");
23.out.write("Connected!");
24.}
25.catch(SQLException e)
26.{
27.System.out.println("Error!!!!!!" + e);
28.}

Related posts:

  1. JSP tutorial + mysql part II
  2. JSP tutorial
  3. fetch database guna join
  4. Mysql-J Connector
  5. convert dari excel kepada mysql
Posted by h@fr|z   @   23 December 2009 0 comments
Tags : , ,

Share This Post

RSS Digg Twitter StumbleUpon Delicious Technorati

0 Comments

No comments yet. Be the first to leave a comment !
Leave a Comment

Previous Post
«
Next Post
»
G-scale designed by Make Your Own Website In conjunction with Web Hosting   |   Watch Movies Online   |   Computer Repair