Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- import java.util.ResourceBundle;
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author user
- */
- public class CPS4Layer {
- private String driver;
- private String url;
- private String password;
- private String user;
- private Connection conn;
- public CPS4Layer() {
- ResourceBundle sql = ResourceBundle.getBundle("boot.Information");
- this.url = sql.getString("url");
- this.user = sql.getString("user");
- this.password = sql.getString("password");
- this.driver = sql.getString("driver");
- }
- public void connect() {
- try {
- Class.forName(driver);
- conn = DriverManager.getConnection(url, user, password);
- }catch(Exception e) {
- e.printStackTrace();
- }
- }
- public void disconnect() {
- try {
- if(conn!=null) conn.close();
- }catch(SQLException e) {
- e.printStackTrace();
- }
- }
- public PreparedStatement getPreparedStatement(String sql) {
- if(conn==null) return null;
- try {
- return conn.prepareStatement(sql);
- }catch(SQLException e) {
- e.printStackTrace();
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement