package curveprj;
import java.sql.*;
public class DBManager {
private static DBManager instance = null;
private Connection con=null;
private DBManager() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static synchronized DBManager getInstance() {
//这个方法比上面有所改进,不用每次都进行生成对象,只是第一次
//使用时生成实例,提高了效率!
if (instance==null)
instance=new DBManager();
return instance;
}
public boolean ConnectionDB(String url,String user ,String password){
if(con ==null){
try {
Class.forName("oracle.jdbc.driver.OracleDriver", true,
this.getClass().getClassLoader());
} catch (ClassNotFoundException ex) {
System.out.println("Could not load the driver");
ex.printStackTrace() ;
return false;
}
try {
con = DriverManager.getConnection("jdbc:oracle:thin:@" + url, user,password);
//conn = DriverManager.getConnection("jdbc:oracle:thin:@61.167.119.194:1521:shuhui", "shuhuitest","test");
//stmt=con.createStatement();
} catch (SQLException ex1) {
System.out.println("Could not connect the oracle");
ex1.printStackTrace() ;
return false;
}
}
return true;
}
public void CloseDB(){
try{
//dbcm.freeConnection(dbname, this.con);
con.close();
}
catch(Exception e){
System.out.println("con clsoe make errer") ;
e.printStackTrace();
}
}
public static void main(String[] args) {
DBManager dbmanager = new DBManager();
}
public Connection getCon() {
return con;
}
public void setCon(Connection con) {
this.con = con;
}
private void jbInit() throws Exception {
}
}
分享到:
相关推荐
单件模式(Single Pattern),C#的实现代码。根据不同需求的5种实现方式。
高效的单次频繁模式挖掘--Efficient single-pass frequent pattern mining.pdf
麻省理工学院执照构建库和独立样本cmake -Hall -Bbuildcmake --build build# run standalone `glob` sample./build/standalone/glob --help用法// Match on a single patternfor ( auto & p : glob::glob( " ~/.b* ...
The main objective of this book is to present the basic theoretical principles behind modern fringe-pattern analysis as applied to optical metrology. In addition to this, for the experimentalist, we ...
This book uses tons of concepts like Solid Principles, Repository Pattern, Unit of Work Pattern, Entity Framework, Design Principles and many other things to name a few. Hence, Author expects to have...
typically require each row-column intersection to contain a single, scalar value. Mon‐ goDB BSON documents allow for more complex structure by supporting arrays of val‐ ues (where each array itself ...
of single-entity representation versus multiple-entity representation. A comibined syntactic-semantic approach based on attributed grammars is suggested. Svntax-semantics tradeoff in pattern ...
获取到【文件夹】名称: single_pattern 获取到【文件夹】名称: status_pattern 获取到【文件夹】名称: strategy_pattern 获取到【文件夹】名称: templet_pattern 获取到【文件夹】名称: visitor_pattern
Abstract—Based on demands in proxy pattern, this article proposes informatization solution of proxy pattern which includes enterprise management, proxy management, franchisee management and supply ...
There is a lot of written material available on design patterns, but scattered and not in one single reference source. Also, many of these examples are unnecessarily big and complex.
15Matlab files for various types of beamforming for custom 1D- Calculate and look at beampattern/array pattern/array factor for 1D- Calculate and look at beampattern for delay-and-sum and minimum ...
26.1 单一职责原则【SINGLE RESPONSIBILITY PRINCIPLE】 290 26.2 里氏替换原则【LISKOV SUBSTITUTION PRINCIPLE】 297 26.3 依赖倒置原则【DEPENDENCE INVERSION PRINCIPLE】 309 26.4 接口隔离原则...
* Explore useful habits for writing high-quality JavaScript code, such as avoiding globals, using single var declarations, and more * Learn why literal notation patterns are simpler alternatives to ...
There is a lot of written material available on design patterns, but scattered and not in one single reference source. Also, many of these examples are unnecessarily big and complex. Table of ...
react-refluxjs-单页状态模式 这是一种用于为reflect.js中的页面实现单一状态层次结构的模式。 它使用了。 所有Reflux商店的更改都会触发到顶级商店 顶级React组件侦听顶级Reflux商店这是侦听商店的唯一组件 ...
// no config file, default to this loader - we might be in a 'single' env. commonLoader=this.getClass().getClassLoader(); } //创建catalinaLoader、sharedLoader catalinaLoader = createClassLoader...
Designing Software Product Lines with UML: From Use Cases to Pattern-Based Software Architectures 第一部分 Long a standard practice in traditional manufacturing, the concept of product lines is ...
Designing Software Product Lines with UML: From Use Cases to Pattern-Based Software Architectures 第二部分 Long a standard practice in traditional manufacturing, the concept of product lines is ...
角度模式Spring (Spring MVC, Spring Data) Angular.js Hibernate(Oracle) ... P1 Single Detail, - image : images/1.png, - desc : Perform on a screen for CRUD actions., - sample : apps/pattern1/index.ht
#对饮品店的模拟系统 ####系统的入口为Test.java文件的main方法 ###模拟一个饮品店 制作饮品过程--> 使用模板方法设计模式 顾客点饮 饮单设计--->使用工场设计模式 饮品店账户记账 考虑到记账的员工...单例模式