Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tzt;
- import java.sql.*;
- /**
- *
- * @author pieter
- */
- public class DBWrapper {
- private static Connection connection = null;
- private static Statement statement = null;
- private static boolean initialized;
- public static void initialize() {
- if(initialized) {
- return;
- }
- try {
- Class.forName("com.mysql.jdbc.Driver");
- connection = DriverManager.getConnection("jdbc:mysql://localhost/TZT", "root", "");
- statement = connection.createStatement();
- } catch (Exception e) {
- initialized = true;
- }
- }
- public static ResultSet executeQuery(String q) {
- ResultSet set = null;
- try {
- set = statement.executeQuery(q);
- } catch(Exception e) {}
- return set;
- }
- public static int executeUpdate(String q) {
- int set = 0;
- try {
- set = statement.executeUpdate(q);
- } catch(Exception e) {}
- return set;
- }
- public static void close() {
- try {
- statement.close();
- connection.close();
- } catch (Exception e) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement