Warning: Invalid argument supplied for foreach() in /home/e1rsbco/public_html/hafriz/wp-content/plugins/facebook-import-comments/classes/FacebookCommentImporter.php on line 185
Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X
Post

MySQL + Tomcat JSP Test Script

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
  • hajar da tryconnection ney. tapi nape x kuar pape ea. ? da tu. x tau. problem ke x. cane tu ea ?

    hajar

    22 December 2010

  • so maksudnye there is something wrong with your apache lah tu, cube buat simple jsp coding tengok dia boleh baca tak.

    sepatutnya kalau hajar tengok coding atas tu, dia akan kluar error atau connected.

    h@fr|z

    24 December 2010

Leave a comment  

name*

email*

website

Submit comment