Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Singleton {
- private static Singleton INSTANCE = null;
- private Connection connection;
- public Singleton()
- {
- }
- public static Singleton getInstance()
- {
- if(INSTANCE == null)
- {
- INSTANCE = new Singleton();
- }
- return INSTANCE;
- }
- public void setSingletonConnexion(String URL, String userName, String password, String networkAlias) throws SQLException, ClassNotFoundException
- {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- System.setProperty("pathOfTNS");
- //System.out.println("driver ok");
- this.connection = DriverManager.getConnection("jdbc:oracle:thin:@"+URL+":PORT:SID", userName,password);
- System.out.println("CO OK");
- ResultSet rs = this.connection.createStatement().executeQuery("SELECT * FROM TABLE");
- if(rs.next())
- {
- System.out.println(rs.getString(5));
- }
- }
- public Connection getConnection()
- {
- return this.connection;
- }
Add Comment
Please, Sign In to add comment