package admin.dbmanagement;
import java.net.URI;
public class DBParameterConfiger {
private DBParameterConfiger() {
}
public static void main(String[] args) {
DBParameterConfiger DBParameterConfiger1 = new DBParameterConfiger();
try{
DBParameterConfiger1.reloadProp(null);
}catch(Exception e){
System.out.println(e.toString());
}
}
private static DBParameterConfiger myDBParameterConfiger=null;
private static java.util.Properties dbparameters=null;
public static DBParameterConfiger getInstance(){
synchronized("DBParameterConfiger"){
if(DBParameterConfiger.myDBParameterConfiger==null){
DBParameterConfiger.myDBParameterConfiger=new DBParameterConfiger();
}
}
return DBParameterConfiger.myDBParameterConfiger;
}
public java.util.Properties reloadProp(java.util.Properties prop) throws java.lang.Exception{
synchronized(this){
try{
try{
if(this.dbparameters==null){
this.dbparameters=new java.util.Properties();
java.io.File file=new java.io.File("conf","conf.xml");
javax.xml.parsers.DocumentBuilderFactory dbf=javax.xml.parsers.DocumentBuilderFactory.newInstance();
javax.xml.parsers.DocumentBuilder db=dbf.newDocumentBuilder();
//root node
org.w3c.dom.Document doc=db.parse(file);
org.w3c.dom.NodeList nodelist=doc.getChildNodes();
//first node
org.w3c.dom.Node node=nodelist.item(0);
org.w3c.dom.NodeList nodeChildlist=node.getChildNodes();
int childindex=nodeChildlist.getLength();
for(int i=0;i<childindex;i++){
//seconde node
org.w3c.dom.Node nodeChild=nodeChildlist.item(i);
if(nodeChild.getNodeType()==org.w3c.dom.Node.TEXT_NODE){
}else{
org.w3c.dom.Node nodechildchild=nodeChild.getChildNodes().item(0);
this.dbparameters.put(nodeChild.getNodeName(),nodechildchild.getNodeValue().trim());
System.out.println(nodechildchild.getNodeValue().trim());
}
}
}//end of if(this.dbparameters==null)
}catch(Exception e){
throw new Exception("从配置参数文件中读数错误!"+e.toString());
// System.out.println(e.toString());
}
try{
if(prop==null){
java.util.Properties propReturn=(java.util.Properties )this.dbparameters.clone();
return propReturn;
}
}catch(Exception e){
throw new Exception("数据参数属性页拷贝复制错误!"+e.toString());
}
try{
this.dbparameters=new java.util.Properties();
java.io.File file=new java.io.File("conf","conf.xml");
javax.xml.parsers.DocumentBuilderFactory dbf=javax.xml.parsers.DocumentBuilderFactory.newInstance();
javax.xml.parsers.DocumentBuilder db=dbf.newDocumentBuilder();
//root node
org.w3c.dom.Document doc=db.parse(file);
org.w3c.dom.NodeList nodelist=doc.getChildNodes();
//first node
org.w3c.dom.Node node=nodelist.item(0);
org.w3c.dom.NodeList nodeChildlist=node.getChildNodes();
int childindex=nodeChildlist.getLength();
for(int i=0;i<childindex;i++){
//seconde node
org.w3c.dom.Node nodeChild=nodeChildlist.item(i);
if(nodeChild.getNodeType()==org.w3c.dom.Node.TEXT_NODE){
}else{
org.w3c.dom.Node nodechildchild=nodeChild.getChildNodes().item(0);
if(nodeChild.getNodeName().equalsIgnoreCase("Databasetype")){
this.dbparameters.put("Databasetype",prop.get("Databasetype"));
nodechildchild.setNodeValue(prop.get("Databasetype").toString());
}
else if(nodeChild.getNodeName().equalsIgnoreCase("DatabaseDirver")){
this.dbparameters.put("DatabaseDirver",prop.get("DatabaseDirver"));
nodechildchild.setNodeValue(prop.get("DatabaseDirver").toString());
}
else if(nodeChild.getNodeName().equalsIgnoreCase("DatabaseUrl")){
this.dbparameters.put("DatabaseUrl",prop.get("DatabaseUrl"));
nodechildchild.setNodeValue(prop.get("DatabaseUrl").toString());
}
else if(nodeChild.getNodeName().equalsIgnoreCase("DatabaseUser")){
this.dbparameters.put("DatabaseUser",prop.get("DatabaseUser"));
nodechildchild.setNodeValue(prop.get("DatabaseUser").toString());
}
else if(nodeChild.getNodeName().equalsIgnoreCase("DatabasePassword")){
this.dbparameters.put("DatabasePassword",prop.get("DatabasePassword"));
nodechildchild.setNodeValue(prop.get("DatabasePassword").toString());
}
else if(nodeChild.getNodeName().equalsIgnoreCase("DatabasePoolsize")){
this.dbparameters.put("DatabasePoolsize",prop.get("DatabasePoolsize"));
nodechildchild.setNodeValue(prop.get("DatabasePoolsize").toString());
}
System.out.println(nodechildchild.getNodeValue().trim());
}
}
return this.dbparameters;
}catch(Exception e){
throw new Exception("设置数据参数属性页错误!"+e.toString());
}
}catch(Exception e){
this.dbparameters=null;
throw new Exception(e.toString());
}
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
使用java语言编写的数据库连接池,实现数据库与jsp文件的连接.zip
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共4个文件
java:3个
txt:1个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 108 浏览量
2024-04-24
16:52:31
上传
评论
收藏 4KB ZIP 举报
温馨提示
使用java语言编写的数据库连接池,实现数据库与jsp文件的连接
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![jar](https://img-home.csdnimg.cn/images/20210720083455.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/TXT.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
共 4 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
m0_74456535
- 粉丝: 91
- 资源: 725
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)