📄 nseer_db.java
字号:
/*
*this file is part of nseer erp
*Copyright (C)2006-2010 Nseer(Beijing) Technology co.LTD/http://www.nseer.com
*
*This program is free software; you can redistribute it and/or
*modify it under the terms of the GNU General Public License
*as published by the Free Software Foundation; either
*version 2 of the License, or (at your option) any later version.
*/
package include.nseer_db;
import java.io.*;
import java.sql.*;
import java.util.Properties;
public class nseer_db
{
private Connection a;
private Statement statement;
private String drivername;
private String database;
private String url1;
private String url2;
public nseer_db(String s)
{
getProperty();
database = s;
String s1 = url1 + s + "?" + url2;
String s2 = drivername;
try
{
Class.forName(s2);
}
catch(ClassNotFoundException classnotfoundexception)
{
classnotfoundexception.printStackTrace();
}
try
{
a = DriverManager.getConnection(s1);
statement = a.createStatement();
}
catch(SQLException sqlexception)
{
sqlexception.printStackTrace();
}
}
public void close()
{
try
{
statement.close();
a.close();
}
catch(SQLException sqlexception)
{
sqlexception.printStackTrace();
}
}
public ResultSet executeQuery(String s)
{
ResultSet resultset = null;
try
{
resultset = statement.executeQuery(s);
}
catch(SQLException sqlexception)
{
sqlexception.printStackTrace();
}
return resultset;
}
public void executeUpdate(String s)
{
try
{
statement.executeUpdate(s);
}
catch(SQLException sqlexception)
{
sqlexception.printStackTrace();
}
}
public String getTable()
{
return database;
}
public void getProperty()
{
Properties properties = new Properties();
Properties properties1 = new Properties();
try
{
InputStream inputstream = getClass().getClassLoader().getResourceAsStream("/conf/db.properties");
InputStream inputstream1 = getClass().getClassLoader().getResourceAsStream("/conf/dbip.properties");
properties.load(inputstream);
properties1.load(inputstream1);
if(inputstream != null)
inputstream.close();
inputstream1.close();
}
catch(IOException ex)
{
System.err.println("Open Propety File Error");
}
drivername = properties.getProperty("DRIVER");
url1 = properties.getProperty("URL1")+properties1.getProperty("IP")+":3306/";
url2 = properties.getProperty("URL2");
}
public void setTable(String s)
{
database = s;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -