source: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/util/GS3SQLConnectionFactory.java@ 6897

Last change on this file since 6897 was 5800, checked in by cs025, 21 years ago

Adding gs3build

  • Property svn:keywords set to Author Date Id Revision
File size: 1.4 KB
Line 
1package org.greenstone.gsdl3.gs3build.util;
2
3import java.sql.Connection;
4import java.sql.DriverManager;
5import java.sql.SQLException;
6
7public class GS3SQLConnectionFactory
8{
9 public static Connection reconnect(String database)
10 {
11 try {
12 Class.forName("com.mysql.jdbc.Driver").newInstance();
13
14 Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/"+database+"?user=gsdl3admin"/*&password=greenstone"*/);
15 return connection;
16 }
17 catch (SQLException sqlEx)
18 { System.out.println(sqlEx.toString());
19 }
20 catch (Exception ex)
21 { System.out.println(ex.toString());
22 return null;
23 }
24 return null;
25 }
26
27 public static GS3SQLConnection /*GS3SQLConnection*/ createConnection(String database)
28 {
29 try
30 { Class.forName("com.mysql.jdbc.Driver").newInstance();
31
32 Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/"+database+"?user=gsdl3admin"/*&password=greenstone"*/);
33 return new GS3SQLConnection(connection);
34 }
35 catch (SQLException sqlEx)
36 { System.out.println(sqlEx.toString());
37 }
38 catch (Exception ex)
39 { System.out.println(ex.toString());
40 return null;
41 }
42 return null;
43 }
44
45 public static GS3SQLConnection createConnection()
46 { return createConnection("test");
47 }
48
49 public static void main(String args[])
50 { GS3SQLConnection connection = createConnection();
51 connection.initCollection("maya");
52 }
53}
Note: See TracBrowser for help on using the repository browser.