提交 e979821e authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Java 7 and Android load drivers from META-INF/services/java.sql.Driver

上级 f585c6e9
......@@ -1065,7 +1065,6 @@ import java.sql.*;
import java.util.*;
public class Test {
public static void main(String[] args) throws Exception {
Class.forName("org.h2.Driver");
String url = "jdbc:h2:~/test";
Properties prop = new Properties();
prop.setProperty("user", "sa");
......@@ -1083,7 +1082,6 @@ public class Test {
}
</pre>
<p>
This example requires Java 1.6.
When using Swing, use <code>javax.swing.JPasswordField</code>.
</p>
......
......@@ -169,7 +169,6 @@ Reference:
<h2><a href="tutorial.html#connecting_using_jdbc">Using the JDBC API</a></h2>
<pre>
Class.forName("org.h2.Driver");
Connection conn = DriverManager.
getConnection("jdbc:h2:~/test");
conn.close();
......
......@@ -117,7 +117,6 @@ and the database URL starts with <code>jdbc:h2:</code>.
To connect to a database using JDBC, use the following code:
</p>
<pre>
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:~/test", "sa", "");
</pre>
......
......@@ -669,7 +669,6 @@ and user passwords are case sensitive. Here is an example to connect to a
password-encrypted database:
</p>
<pre>
Class.forName("org.h2.Driver");
String url = "jdbc:h2:~/test;CIPHER=AES";
String user = "sa";
String pwds = "filepwd userpwd";
......
......@@ -456,7 +456,6 @@ import java.sql.*;
public class Test {
public static void main(String[] a)
throws Exception {
Class.forName("org.h2.Driver");
Connection conn = DriverManager.
getConnection("jdbc:h2:~/test", "sa", "");
// add application code here
......@@ -465,8 +464,7 @@ public class Test {
}
</pre>
<p>
This code first loads the driver (<code>Class.forName(...)</code>)
and then opens a connection (using <code>DriverManager.getConnection()</code>).
This code opens a connection (using <code>DriverManager.getConnection()</code>).
The driver name is <code>"org.h2.Driver"</code>.
The database URL always needs to start with <code>jdbc:h2:</code>
to be recognized by this database. The second parameter in the <code>getConnection()</code> call
......@@ -867,7 +865,6 @@ String url = "jdbc:h2:/data/data/" +
";FILE_LOCK=FS" +
";PAGE_SIZE=1024" +
";CACHE_SIZE=8192";
Class.forName("org.h2.Driver");
conn = DriverManager.getConnection(url);
...
</pre>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论