sqllogic.java
来自「METAmorphoses is a system for flexible a」· Java 代码 · 共 56 行
JAVA
56 行
package cz.cvut.felk.cs.metamorphoses.template;import java.sql.*;/** * <p>The simle database access layer for the processor.</p> * <p> * <b>History:</b><br/> * Created: 5.3.2004<br/> * Last change: 5.3.2004<br/> * </p> * @author Martin Svihla (martin@svihla.net) */public class SqlLogic { Connection conn; protected void connect( String driverName, String jdbcUrl, String user, String password) throws SQLException, ClassNotFoundException { String url = ""; this.testDriver(driverName); url = jdbcUrl + "?user=" + user + "&password=" + password; this.conn = DriverManager.getConnection(url); } protected void disconnect() throws SQLException { this.conn.close(); } /** * execute a simple SQL query * @param sqlStatement - a statement to be executed * @return a result set * @throws SQLException */ protected ResultSet executeQuery(String sqlStatement) throws SQLException { Statement s = this.conn.createStatement(); ResultSet rs = s.executeQuery(sqlStatement); return rs; } /** * Checks whether the MySQL JDBC Driver is installed * */ protected void testDriver(String driverName) throws ClassNotFoundException { Class.forName(driverName); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?