KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mockobjects > examples > calcserver > Database


1 package com.mockobjects.examples.calcserver;
2
3 import java.sql.Connection JavaDoc;
4 import java.sql.DriverManager JavaDoc;
5 import javax.servlet.ServletException JavaDoc;
6
7 /**
8  * Creation date: (18/Mar/01 6:21 pm)
9  * @author:
10  */

11 public class Database {
12
13     /**
14      * Database constructor comment.
15      */

16     public Database() {
17         super();
18     }
19
20
21     public static Connection JavaDoc createConnection() throws ServletException JavaDoc {
22         try {
23             Class.forName("org.gjt.mm.mysql.Driver").newInstance();
24
25             return DriverManager.getConnection("jdbc:mysql:///test");
26         } catch (Exception JavaDoc ex) {
27             throw new ServletException JavaDoc(ex);
28         }
29     }
30 }
Popular Tags