List of usage examples for java.lang ClassNotFoundException printStackTrace
public void printStackTrace()
From source file:com.jt.dbcp.example.ManualPoolingDataSourceExample.java
public static void main(String[] args) throws SQLException { ///*from w w w.j a v a2s . c o m*/ // First we load the underlying JDBC driver. // You need this if you don't use the jdbc.drivers // system property. // System.out.println("Loading underlying JDBC driver."); try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } System.out.println("Done."); // // Then, we set up the PoolingDataSource. // Normally this would be handled auto-magically by // an external configuration, but in this example we'll // do it manually. // System.out.println("Setting up data source."); DataSource dataSource = setupDataSource(args[0]); System.out.println("Done."); // // Now, we can use JDBC DataSource as we normally would. // Connection conn = null; Statement stmt = null; ResultSet rset = null; try { System.out.println("Creating connection."); conn = dataSource.getConnection(); System.out.println("Creating statement."); stmt = conn.createStatement(); System.out.println("Executing statement."); rset = stmt.executeQuery(args[1]); System.out.println("Results:"); int numcols = rset.getMetaData().getColumnCount(); int count = 0; while (rset.next()) { count++; if (count == 10) { break; } for (int i = 1; i <= numcols; i++) { System.out.print("\t" + rset.getString(i)); } System.out.println(""); } printDataSourceStats(dataSource); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (rset != null) rset.close(); } catch (Exception e) { } try { if (stmt != null) stmt.close(); } catch (Exception e) { } try { if (conn != null) conn.close(); } catch (Exception e) { } // shutdownDataSource(dataSource); } }
From source file:JDBCPool.dbcp.demo.offical.PoolingDriverExample.java
public static void main(String[] args) { // First we load the underlying JDBC driver. // You need this if you don't use the jdbc.drivers system property. System.out.println("Loading underlying JDBC driver."); try {/*from w ww .j av a 2 s .co m*/ Class.forName("com.cloudera.impala.jdbc4.Driver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } System.out.println("Done."); // Then we set up and register the PoolingDriver. // Normally this would be handled auto-magically by an external configuration, but in this example we'll do it manually. System.out.println("Setting up driver."); try { setupDriver(args[0]); } catch (Exception e) { e.printStackTrace(); } System.out.println("Done."); // // Now, we can use JDBC as we normally would. // Using the connect string // jdbc:apache:commons:dbcp:example // The general form being: // jdbc:apache:commons:dbcp:<name-of-pool> // Connection conn = null; Statement stmt = null; ResultSet rset = null; try { System.out.println("Creating connection."); conn = DriverManager.getConnection("jdbc:apache:commons:dbcp:example"); System.out.println("Creating statement."); stmt = conn.createStatement(); System.out.println("Executing statement."); rset = stmt.executeQuery(args[1]); System.out.println("Results:"); int numcols = rset.getMetaData().getColumnCount(); while (rset.next()) { for (int i = 1; i <= numcols; i++) { System.out.print("\t" + rset.getString(i)); } System.out.println(""); } } catch (SQLException e) { e.printStackTrace(); } finally { try { if (rset != null) rset.close(); } catch (Exception e) { } try { if (stmt != null) stmt.close(); } catch (Exception e) { } try { if (conn != null) conn.close(); } catch (Exception e) { } } // Display some pool statistics try { printDriverStats(); } catch (Exception e) { e.printStackTrace(); } // closes the pool try { shutdownDriver(); } catch (Exception e) { e.printStackTrace(); } }
From source file:PoolingDriverExample.java
public static void main(String[] args) { ///* ww w .j a v a 2 s.c o m*/ // First we load the underlying JDBC driver. // You need this if you don't use the jdbc.drivers // system property. // System.out.println("Loading underlying JDBC driver."); try { Class.forName("org.h2.Driver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } System.out.println("Done."); // // Then we set up and register the PoolingDriver. // Normally this would be handled auto-magically by // an external configuration, but in this example we'll // do it manually. // System.out.println("Setting up driver."); try { setupDriver(args[0]); } catch (Exception e) { e.printStackTrace(); } System.out.println("Done."); // // Now, we can use JDBC as we normally would. // Using the connect string // jdbc:apache:commons:dbcp:example // The general form being: // jdbc:apache:commons:dbcp:<name-of-pool> // Connection conn = null; Statement stmt = null; ResultSet rset = null; try { System.out.println("Creating connection."); conn = DriverManager.getConnection("jdbc:apache:commons:dbcp:example"); System.out.println("Creating statement."); stmt = conn.createStatement(); System.out.println("Executing statement."); rset = stmt.executeQuery(args[1]); System.out.println("Results:"); int numcols = rset.getMetaData().getColumnCount(); while (rset.next()) { for (int i = 1; i <= numcols; i++) { System.out.print("\t" + rset.getString(i)); } System.out.println(""); } } catch (SQLException e) { e.printStackTrace(); } finally { try { if (rset != null) rset.close(); } catch (Exception e) { } try { if (stmt != null) stmt.close(); } catch (Exception e) { } try { if (conn != null) conn.close(); } catch (Exception e) { } } // Display some pool statistics try { printDriverStats(); } catch (Exception e) { e.printStackTrace(); } // closes the pool try { shutdownDriver(); } catch (Exception e) { e.printStackTrace(); } }
From source file:ManualPoolingDriverExample.java
public static void main(String[] args) { ///* w w w .j a v a 2 s . co m*/ // First we load the underlying JDBC driver. // You need this if you don't use the jdbc.drivers // system property. // System.out.println("Loading underlying JDBC driver."); try { Class.forName("oracle.jdbc.driver.OracleDriver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } System.out.println("Done."); // // Then we set up and register the PoolingDriver. // Normally this would be handled auto-magically by // an external configuration, but in this example we'll // do it manually. // System.out.println("Setting up driver."); try { setupDriver(args[0]); } catch (Exception e) { e.printStackTrace(); } System.out.println("Done."); // // Now, we can use JDBC as we normally would. // Using the connect string // jdbc:apache:commons:dbcp:example // The general form being: // jdbc:apache:commons:dbcp:<name-of-pool> // Connection conn = null; Statement stmt = null; ResultSet rset = null; try { System.out.println("Creating connection."); conn = DriverManager.getConnection("jdbc:apache:commons:dbcp:example"); System.out.println("Creating statement."); stmt = conn.createStatement(); System.out.println("Executing statement."); rset = stmt.executeQuery(args[1]); System.out.println("Results:"); int numcols = rset.getMetaData().getColumnCount(); while (rset.next()) { for (int i = 1; i <= numcols; i++) { System.out.print("\t" + rset.getString(i)); } System.out.println(""); } } catch (SQLException e) { e.printStackTrace(); } finally { try { if (rset != null) rset.close(); } catch (Exception e) { } try { if (stmt != null) stmt.close(); } catch (Exception e) { } try { if (conn != null) conn.close(); } catch (Exception e) { } } // Display some pool statistics try { printDriverStats(); } catch (Exception e) { e.printStackTrace(); } // closes the pool try { shutdownDriver(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.jt.dbcp.example.ManualPoolingDriverExample.java
public static void main(String[] args) { ///*from w w w .j av a2 s. co m*/ // First we load the underlying JDBC driver. // You need this if you don't use the jdbc.drivers // system property. // System.out.println("Loading underlying JDBC driver."); try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } System.out.println("Done."); // // Then we set up and register the PoolingDriver. // Normally this would be handled auto-magically by // an external configuration, but in this example we'll // do it manually. // System.out.println("Setting up driver."); try { setupDriver(args[0]); } catch (Exception e) { e.printStackTrace(); } System.out.println("Done."); // // Now, we can use JDBC as we normally would. // Using the connect string // jdbc:apache:commons:dbcp:example // The general form being: // jdbc:apache:commons:dbcp:<name-of-pool> // Connection conn = null; Statement stmt = null; ResultSet rset = null; try { System.out.println("Creating connection."); //pool conn = DriverManager.getConnection("jdbc:apache:commons:dbcp:example"); System.out.println("Creating statement."); stmt = conn.createStatement(); System.out.println("Executing statement."); rset = stmt.executeQuery(args[1]); System.out.println("Results:"); int numcols = rset.getMetaData().getColumnCount(); int count = 0; while (rset.next()) { count++; if (count == 10) { break; } for (int i = 1; i <= numcols; i++) { System.out.print("\t" + rset.getString(i)); } System.out.println(""); } } catch (SQLException e) { e.printStackTrace(); } finally { try { if (rset != null) rset.close(); } catch (Exception e) { } try { if (stmt != null) stmt.close(); } catch (Exception e) { } try { if (conn != null) conn.close(); } catch (Exception e) { } } // Display some pool statistics try { printDriverStats(); } catch (Exception e) { e.printStackTrace(); } // closes the pool try { shutdownDriver(); } catch (Exception e) { e.printStackTrace(); } }
From source file:AppMain.java
public static void main(String[] list) throws IOException { setProxy();/* ww w. j ava 2 s .c o m*/ System.out.println("loading Italian model..."); ItalianModel im = null; try { im = new ItalianModel(); } catch (ClassNotFoundException e) { e.printStackTrace(); System.exit(2); } catch (SQLException e) { e.printStackTrace(); } System.out.println("starting matcher..."); fm = new FlexiMatcher(); fm.bind("it-pos", new ItPosRuleFactory(im)); fm.bind("it-token", new ItTokenRuleFactory(im)); fm.bind("it-verb-conjugated", new ItSpecificVerbRuleFactory(im)); fm.bind("it-verb-form", new ItVerbFormRuleFactory(im)); String fname = "rule_list.tsv"; FileTagLoader.readTagsFromTSV(fname, fm); fwTag = new FileWriter(fname, true); System.out.println("starting server at port " + portToUse + "..."); Container container = new AppMain(); Server server; server = new ContainerServer(container); @SuppressWarnings("resource") Connection connection = new SocketConnection(server); SocketAddress address = new InetSocketAddress(portToUse); connection.connect(address); }
From source file:MethodCountingHandler.java
/** * Run the demonstration./* w w w .ja v a 2 s. co m*/ * * @param args Command line arguments (ignored). */ public static final void main(final String[] args) { SomeClass proxy = SomeClassFactory.getDynamicSomeClassProxy(); System.out.println(proxy.getClass().getName()); try { Class cl = Class.forName("$Proxy0"); // <== Dangerous! System.out.println(cl.getName()); } catch (final ClassNotFoundException ex) { ex.printStackTrace(); } }
From source file:chibi.gemmaanalysis.cli.deprecated.ProbeMapperGui.java
/** * @param args/*ww w . j a v a 2 s. c o m*/ */ public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } ProbeMapperGui pgmg = new ProbeMapperGui(); pgmg.pack(); pgmg.setVisible(true); }
From source file:org.apache.usergrid.tools.Command.java
/** * @param args/*w w w . j av a 2 s. c o m*/ */ public static void main(String[] args) { if ((args == null) || (args.length < 1)) { System.out.println("No command specified"); return; } String command = args[0]; Class<?> clazz = null; try { clazz = Class.forName(command); } catch (ClassNotFoundException e) { } if (clazz == null) { try { clazz = Class.forName("org.apache.usergrid.tools." + command); } catch (ClassNotFoundException e) { } } if (clazz == null) { try { clazz = Class.forName("org.apache.usergrid.tools." + StringUtils.capitalize(command)); } catch (ClassNotFoundException e) { e.printStackTrace(); } } if (clazz == null) { System.out.println("Unable to find command"); return; } args = Arrays.copyOfRange(args, 1, args.length); try { if (ToolBase.class.isAssignableFrom(clazz)) { ToolBase tool = (ToolBase) clazz.newInstance(); tool.startTool(args); } else { MethodUtils.invokeStaticMethod(clazz, "main", (Object) args); } } catch (NoSuchMethodException e) { System.out.println("Unable to invoke command"); e.printStackTrace(); } catch (IllegalAccessException e) { System.out.println("Unable to invoke command"); e.printStackTrace(); } catch (InvocationTargetException e) { System.out.println("Error while invoking command"); e.printStackTrace(); } catch (InstantiationException e) { System.out.println("Error while instantiating tool object"); e.printStackTrace(); } }
From source file:org.usergrid.benchmark.boostrap.Command.java
/** * @param args/* ww w. ja v a2 s. co m*/ */ public static void main(String[] args) { if ((args == null) || (args.length < 1)) { System.out.println("No command specified"); return; } String command = args[0]; Class<?> clazz = null; try { clazz = Class.forName(command); } catch (ClassNotFoundException e) { } if (clazz == null) { try { clazz = Class.forName("org.usergrid.benchmark.commands." + command); } catch (ClassNotFoundException e) { } } if (clazz == null) { try { clazz = Class.forName("org.usergrid.benchmark.commands." + StringUtils.capitalize(command)); } catch (ClassNotFoundException e) { e.printStackTrace(); } } if (clazz == null) { System.out.println("Unable to find command"); return; } args = Arrays.copyOfRange(args, 1, args.length); try { if (ToolBase.class.isAssignableFrom(clazz)) { ToolBase tool = (ToolBase) clazz.newInstance(); tool.startTool(args); } else { MethodUtils.invokeStaticMethod(clazz, "main", (Object) args); } } catch (NoSuchMethodException e) { System.out.println("Unable to invoke command"); e.printStackTrace(); } catch (IllegalAccessException e) { System.out.println("Unable to invoke command"); e.printStackTrace(); } catch (InvocationTargetException e) { System.out.println("Error while invoking command"); e.printStackTrace(); } catch (InstantiationException e) { System.out.println("Error while instantiating tool object"); e.printStackTrace(); } }