Guest User

Untitled

a guest
Mar 29th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. String strConnectionURL = "jdbc:derby:/path/to/derby/database;create=false";
  2. Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
  3. Connection connection = DriverManager.getConnection(strConnectionURL);
  4. Statement statement = connection.createStatement();
  5. boolean boResult = statement.execute("SHOW TABLES");
  6. if (boResult) {
  7. System.out.println("yay!");
  8. }
  9.  
  10. java.sql.SQLSyntaxErrorException: Syntax error: Encountered "SHOW" at line 1, column 1.
  11.  
  12. String strConnectionURL = "jdbc:derby:/path/to/derby/db;create=false";
  13. Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
  14. Connection connection = DriverManager.getConnection(strConnectionURL);
  15. CallableStatement statement = connection.prepareCall("SHOW TABLES");
  16. boolean boResult = statement.execute();
  17. if (boResult) {
  18. System.out.println("yippee!");
  19. }
  20.  
  21. java.sql.SQLSyntaxErrorException: Syntax error: Encountered "SHOW" at line 1, column 1.
  22.  
  23. String strConnectionURL = "jdbc:derby:/path/to/db;create=false";
  24. Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
  25. Connection connection = DriverManager.getConnection(strConnectionURL);
  26. DatabaseMetaData dbmd = connection.getMetaData();
  27. ResultSet resultSet = dbmd.getTables(null, null, null, null);
  28. while (resultSet.next()) {
  29. String strTableName = resultSet.getString("TABLE_NAME");
  30. System.out.println("TABLE_NAME is " + strTableName);
  31. }
  32.  
  33. public void showTbls() throws Exception{
  34. String sqlIn = "SHOW TABLES;";
  35. InputStream stream = new ByteArrayInputStream(sqlIn.getBytes(StandardCharsets.UTF_8));
  36. ij.runScript(conn,stream,StandardCharsets.UTF_8.name(), System.out,"UTF-8");
  37. stream.close();
  38. }
  39.  
  40. Statement stmt = conn.createStatement();
  41. ResultSet results = stmt.executeQuery("SELECT * FROM sys.systables");
  42.  
  43. ResultSet results = stmt.executeQuery("SELECT TABLENAME FROM SYS.SYSTABLES WHERE TABLETYPE='T'");
Add Comment
Please, Sign In to add comment