Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: feynman/framework/datastore/DbmsDataStore.java


1   package feynman.framework.datastore;
2   
3   import feynman.framework.system.PhysicalMeasurement;
4   import java.io.*;
5   import java.sql.*;
6   
7   public class DbmsDataStore implements DataStore {
8     
9     // Private instance variables.
10    private Connection conn = null;
11    private Statement stmt = null;
12    private ResultSet rset = null;
13    
14    DbmsDataStore() {
15      // Factory only instantiation.
16    }
17    
18    public void open(String driver) throws ConnectionException {
19      
20      try {
21        Class.forName(driver);
22        
23        conn = DriverManager.getConnection(
24                         "jdbc:postgresql://127.0.0.1/feynman",
25                         "feynman",
26                         "feynman"
27                     );
28  
29      }
30      catch (ClassNotFoundException e) {
31        throw new ConnectionException("Couldn't load database driver: " + e.toString());
32      }
33      catch (SQLException e) {
34        throw new ConnectionException("Couldn't connect to database: " + e.toString());
35      }
36      
37    }
38    
39    public void save(PhysicalMeasurement ps) {
40      //null
41    }
42    
43    public void close() throws ConnectionException {
44      
45      try {
46        conn.close();
47      }
48      catch (SQLException e) {
49        throw new ConnectionException(e.toString());
50      }
51      
52    }
53    
54  }