⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dboperator.java

📁 网上虚拟社区
💻 JAVA
字号:
import java.sql.*;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class DBOperator{
	   private  String url;
	   private  String username;
	   private  String password;
	   private  String driver;
	   	   
	   public DBOperator(){  
		   driver = "sun.jdbc.odbc.JdbcOdbcDriver";
           url = "jdbc:odbc:BankDB";
           username = null;
           password =null;
       }
	   public DBOperator(String driver,String url,String username,String password){
		   this.driver = driver;
		   this.url=url;
		   this.username = username;
		   this.password = password;
	   }
	   public DBOperator(String url,String username,String password){
		   this.url=url;
		   this.username = username;
		   this.password = password;
	   }
	   public DBOperator(String driver,String url){
		   this(driver,url,null,null);
	   }
	   public DBOperator(String url){
		   this(url,null,null);
	   }
	   
	   public  Connection getConnection() throws SQLException {
		   try{
			Class.forName(driver);
		   }
		   catch(ClassNotFoundException ex){
			   System.out.println(ex);
		   }
	       return DriverManager.getConnection(url,username,password);
	   }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -