📄 testtextfile.java
字号:
/* * * Test the textFileDriver * * Copyright 1996, Brian C. Jepson * (bjepson@ids.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */import java.net.URL;import java.sql.*;class testTextFile { public static void main(String argv[]) { // Uncomment the next line to get noisy messages // during the test // // java.sql.DriverManager.setLogStream(System.out); try { // load the driver // Class.forName("textFileDriver"); // the url to the tinySQL data source // String url = "jdbc:tinySQL"; // get the connection // Connection con = DriverManager.getConnection(url, "", ""); // create a statement, create a table, populate // it, and query it // Statement stmt = con.createStatement(); stmt.executeUpdate("CREATE TABLE test (name CHAR(10))"); stmt.executeUpdate("INSERT INTO test (name) VALUES('test')"); ResultSet rs = stmt.executeQuery("SELECT name FROM test"); // fetch the row // rs.next(); // get the column, and see if it matches our expectations // String colval = rs.getString(1); if (colval.startsWith("test")) { System.out.println("textFile JDBC driver installed correctly."); } else { System.out.println("Test was not successful :-("); System.out.println("Got \"" + colval + "\", expected \"test\""); } stmt.close(); con.close(); } catch( Exception e ) { System.out.println(e.getMessage()); e.printStackTrace(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -