QED数据库使用笔记之Developing With QED

来源:互联网 发布:java ftp下载文件代码 编辑:程序博客网 时间:2024/05/21 10:35
 

Connecting to a database

In order to access a database, you need to obtain a JDBC Connection object. There are two basic ways to get a database connection:

Using the JDBC DriverManager interface, you can directly obtain a JDBC Connection, if you know:

  • The name of the JDBC Driver class (com.quadcap.jdbc.JdbcDriver)
  • The database URL (jdbc:qed:database-name)
  • Any connection parameters (see below)

For QED, you could obtain a database connection using code similar to the following:

//获得驱动,建立连接
Class.forName("com.quadcap.jdbc.JdbcDriver");java.sql.Connection conn = java.sql.DriverManager.getConnection("jdbc:qed:mydb");//mydb是要连接的数据库名称

or, to create a new database:

//创建一个新的数据库
Class.forName("com.quadcap.jdbc.JdbcDriver");java.util.Properties p = new java.util.Properties();p.setProperty("create", "true");java.sql.Connection conn = java.sql.DriverManager.getConnection("jdbc:qed:mynewdb", p);

another way to create a new database:

//另外一种创建数据库的方法
Class.forName("com.quadcap.jdbc.JdbcDriver");java.sql.Connection conn = java.sql.DriverManager.getConnection("jdbc:qed:mynewdb;create=true");
 
原创粉丝点击