Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. /*
  2. * This connection specifies create=true in the connection URL to
  3. * cause the database to be created when connecting for the first
  4. * time. To remove the database, remove the directory derbyDB (the
  5. * same as the database name) and its contents.
  6. *
  7. * The directory derbyDB will be created under the directory that
  8. * the system property derby.system.home points to, or the current
  9. * directory (user.dir) if derby.system.home is not set.
  10. */
  11. String protocol = "jdbc:derby:";
  12. String dbName = "derbyDB"; // the name of the database
  13. props.put("user", "user1");
  14. props.put("password", "user1");
  15. Connection conn = DriverManager.getConnection(protocol + dbName
  16. + ";create=true", props);
  17. // Then you can use jdbc classes to create and execute your queries
  18. // For example :
  19. Statement s = conn.createStatement();
  20. // We create a table...
  21. s.execute("create table location(num int, addr varchar(40))");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement