你是怎么学的呢?
我也是刚开始学JAVA的

解决方案 »

  1.   

    你学JAVA多长时间了,还初学者。
    看不懂。
    但支持你,天才.
      

  2.   

    public ReadDb(String Driver) throws Exception {
    this.Driver = Driver;
    this.userName = null;
    this.passWord = null;
    this.dbName = null;
    this.dbAddress = "localhost";
    init();
    } public ReadDb(String Driver, String address) throws Exception {
    this.Driver = Driver;
    this.userName = null;
    this.passWord = null;
    this.dbAddress = address;
    init(); } public ReadDb(String Driver, String address, String dabaseName)
    throws Exception {
    this.Driver = Driver;
    this.userName = null;
    this.passWord = null;
    this.dbName = null;
    this.dbAddress = "localhost";
    this.dbName = dabaseName;
    init();
    } public ReadDb(String Driver, String address, String dabaseName, String name)
    throws Exception {
    this.Driver = Driver;
    this.userName = name;
    this.passWord = null;
    this.dbAddress = address;
    this.dbName = dabaseName;
    init(); } public ReadDb(String Driver, String address, String dabaseName,
    String name, String pw) throws Exception {
    this.Driver = Driver;
    this.userName = name;
    this.passWord = pw;
    this.dbAddress = address;
    this.dbName = dabaseName;
    init(); } private void init() throws Exception {
    if (this.Driver.equals("com.microsoft.jdbc.sqlserver.SQLServerDriver"))
    this.url = "jdbc:microsoft:sqlserver://" + this.dbAddress
    + ";DatabaseName=" + this.dbName;
    else if (this.Driver.equals("oracle.jdbc.driver.OracleDriver"))
    this.url = "jdbc:oracle:thin:@" + this.dbAddress + ":1521:"
    + this.dbName;
    else if (this.Driver.equals("com.ibm.db2.jdbc.app.DB2Driver"))
    this.url = "jdbc:db2://" + this.dbAddress + ":5000/" + this.dbName;
    else if (this.Driver.equals("com.informix.jdbc.IfxDriver"))
    this.url = "jdbc:informix-sqli://" + this.dbAddress + "/"
    + this.dbName + ":INFORMIXSERVER=myserver";
    else if (this.Driver.equals("com.sybase.jdbc.SybDriver"))
    this.url = " jdbc:sybase:Tds:" + this.dbAddress + ":5007/"
    + this.dbName;
    else if (this.Driver.equals("org.gjt.mm.mysql.Driver"))
    this.url = "jdbc:mysql://" + this.dbAddress + "/" + this.dbName
    + "?user=" + this.userName + "&password=" + this.passWord
    + "&useUnicode=true&characterEncoding=8859_1";
    else if (this.Driver.equals("org.postgresql.Driver"))
    this.url = "jdbc:postgresql://" + this.dbAddress + "/"
    + this.dbName;
    else {
    throw new Exception("UNKNOW DATABASE DRIVER");
    }
    }