📄 sqllogic.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -