Java by API/java.sql/DriverPropertyInfo — различия между версиями

Материал из Java эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 14:46, 31 мая 2010

DriverPropertyInfo.choices

 
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
public class Main {
  public static void main(String[] args) throws Exception {
    Class.forName("org.hsqldb.jdbcDriver");
    String url = "jdbc:hsqldb:mem:data/tutorial";
    Driver driver = DriverManager.getDriver(url);
    DriverPropertyInfo[] info = driver.getPropertyInfo(url, null);
    for (int i = 0; i < info.length; i++) {
      System.out.println(info[i].name);
      // Is property value required?
      System.out.println(info[i].required);
      // Get current value
      System.out.println(info[i].value);
      // Get description of property
      System.out.println(info[i].description);
      // Get possible choices for property;
      // if null, value can be any string
      String[] choices = info[i].choices;
      if (choices != null) {
        for (int c = 0; c < choices.length; c++) {
          System.out.println(choices[c]);
        }
      }
    }
  }
}





DriverPropertyInfo.description

 
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
public class Main {
  public static void main(String[] args) throws Exception {
    Class.forName("org.hsqldb.jdbcDriver");
    String url = "jdbc:hsqldb:mem:data/tutorial";
    Driver driver = DriverManager.getDriver(url);
    DriverPropertyInfo[] info = driver.getPropertyInfo(url, null);
    for (int i = 0; i < info.length; i++) {
      System.out.println(info[i].name);
      // Is property value required?
      System.out.println(info[i].required);
      // Get current value
      System.out.println(info[i].value);
      // Get description of property
      System.out.println(info[i].description);
      // Get possible choices for property;
      // if null, value can be any string
      String[] choices = info[i].choices;
      if (choices != null) {
        for (int c = 0; c < choices.length; c++) {
          System.out.println(choices[c]);
        }
      }
    }
  }
}





DriverPropertyInfo.name

 

import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
public class Main {
  public static void main(String[] args) throws Exception {
    Class.forName("org.hsqldb.jdbcDriver");
    String url = "jdbc:hsqldb:mem:data/tutorial";
    Driver driver = DriverManager.getDriver(url);
    DriverPropertyInfo[] info = driver.getPropertyInfo(url, null);
    for (int i = 0; i < info.length; i++) {
      System.out.println(info[i].name);
      // Is property value required?
      System.out.println(info[i].required);
      // Get current value
      System.out.println(info[i].value);
      // Get description of property
      System.out.println(info[i].description);
      // Get possible choices for property;
      // if null, value can be any string
      String[] choices = info[i].choices;
      if (choices != null) {
        for (int c = 0; c < choices.length; c++) {
          System.out.println(choices[c]);
        }
      }
    }
  }
}





DriverPropertyInfo.required

 
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
public class Main {
  public static void main(String[] args) throws Exception {
    Class.forName("org.hsqldb.jdbcDriver");
    String url = "jdbc:hsqldb:mem:data/tutorial";
    Driver driver = DriverManager.getDriver(url);
    DriverPropertyInfo[] info = driver.getPropertyInfo(url, null);
    for (int i = 0; i < info.length; i++) {
      System.out.println(info[i].name);
      // Is property value required?
      System.out.println(info[i].required);
      // Get current value
      System.out.println(info[i].value);
      // Get description of property
      System.out.println(info[i].description);
      // Get possible choices for property;
      // if null, value can be any string
      String[] choices = info[i].choices;
      if (choices != null) {
        for (int c = 0; c < choices.length; c++) {
          System.out.println(choices[c]);
        }
      }
    }
  }
}





DriverPropertyInfo: value

 
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
public class Main {
  public static void main(String[] argv) throws Exception {
    String driverName = "org.gjt.mm.mysql.Driver";
    Class.forName(driverName);
    String url = "jdbc:mysql://a/b";
    Driver driver = DriverManager.getDriver(url);
    DriverPropertyInfo[] info = driver.getPropertyInfo(url, null);
    for (int i = 0; i < info.length; i++) {
      String name = info[i].name;
      boolean isRequired = info[i].required;
      String value = info[i].value;
      String desc = info[i].description;
      String[] choices = info[i].choices;
    }
  }
}