Java examples for JDBC:Connection
Listing All Available Parameters for Creating a JDBC Connection
import java.sql.Driver; import java.sql.DriverManager; import java.sql.DriverPropertyInfo; import java.sql.SQLException; public class Main { public static void main(String[] argv) { try {//from w ww . j av a 2s. c o m // Load the driver String driverName = "org.gjt.mm.mysql.Driver"; // MySQL MM JDBC driver Class.forName(driverName); // Get the Driver instance String url = "jdbc:mysql://a/b"; Driver driver = DriverManager.getDriver(url); // Get available properties DriverPropertyInfo[] info = driver.getPropertyInfo(url, null); for (int i = 0; i < info.length; i++) { // Get name of property String name = info[i].name; // Is property value required? boolean isRequired = info[i].required; // Get current value String value = info[i].value; // Get description of property String desc = info[i].description; // Get possible choices for property; if null, value can be any string String[] choices = info[i].choices; } } catch (ClassNotFoundException e) { // Could not find the database driver } catch (SQLException e) { } } }