List of usage examples for java.lang Class forName
@CallerSensitive public static Class<?> forName(String className) throws ClassNotFoundException
From source file:Main.java
public static void main(String[] argv) throws Exception { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jdbctutorial", "root", "root"); Statement st = con.createStatement(); int n = st.executeUpdate("ALTER TABLE mytable ADD col int"); System.out.println("Query OK, " + n + " rows affected"); }
From source file:Main.java
public static void main(String... args) throws Exception { Class<?> c = Class.forName("java.lang.String"); Constructor[] allConstructors = c.getDeclaredConstructors(); for (Constructor ctor : allConstructors) { Modifier.toString(ctor.getModifiers()); }//w w w . j av a 2 s . c o m }
From source file:Main.java
public static void main(String[] argv) throws Exception { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jdbctutorial", "root", "root"); Statement st = con.createStatement(); int n = st.executeUpdate("ALTER TABLE mytable ADD UNIQUE( colName)"); System.out.println("Query OK, " + n + " rows affected."); }
From source file:Main.java
public static void main(String[] args) throws Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Statement stmt = DriverManager.getConnection("jdbc:odbc:employee").createStatement(); ResultSet rs = stmt.executeQuery("select lastname, firstname, id from [Sheet1$]"); while (rs.next()) { String lname = rs.getString(1); String fname = rs.getString(2); int id = rs.getInt(3); System.out.println(fname + " " + lname + " id : " + id); }/* w ww . j av a 2 s.co m*/ rs.close(); stmt.close(); }
From source file:Main.java
public static void main(String... args) throws Exception { Class<?> c = Class.forName("java.lang.String"); Constructor[] allConstructors = c.getDeclaredConstructors(); for (Constructor ctor : allConstructors) { int searchMod = Modifier.PRIVATE; int mods = accessModifiers(ctor.getModifiers()); if (searchMod == mods) { System.out.println(ctor); }/*from w w w . j a v a 2 s . c om*/ } }
From source file:Main.java
public static void main(String... args) throws Exception { Class<?> c = Class.forName("java.lang.String"); Constructor[] allConstructors = c.getDeclaredConstructors(); for (Constructor ctor : allConstructors) { int searchMod = Modifier.INTERFACE; int mods = accessModifiers(ctor.getModifiers()); if (searchMod == mods) { System.out.println(ctor); }/*from w ww .j a v a2 s.co m*/ } }
From source file:Main.java
public static void main(String... args) throws Exception { Class<?> c = Class.forName("java.lang.String"); Constructor[] allConstructors = c.getDeclaredConstructors(); for (Constructor ctor : allConstructors) { int searchMod = Modifier.VOLATILE; int mods = accessModifiers(ctor.getModifiers()); if (searchMod == mods) { System.out.println(ctor); }//ww w. j a va2 s .c o m } }
From source file:Main.java
public static void main(String[] args) { String name = "java.util.Date"; try {/*w w w .j a va 2s .com*/ Class cl = Class.forName(name); printMethods(cl); } catch (ClassNotFoundException e) { System.out.println("Class not found."); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Properties prop = new Properties(); prop.put("charSet", "iso-8859-7"); prop.put("user", "your username"); prop.put("password", "your password"); // Connect to the database Connection con = DriverManager.getConnection("url", prop); }
From source file:Main.java
public static void main(String... args) throws Exception { Class<?> c = Class.forName("java.lang.String"); Constructor[] allConstructors = c.getDeclaredConstructors(); for (Constructor ctor : allConstructors) { int searchMod = Modifier.STRICT; int mods = accessModifiers(ctor.getModifiers()); if (searchMod == mods) { System.out.println(ctor); }// ww w . ja va 2 s .co m } }