Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DatabaseHandling {
- Connection conn;
- public DatabaseHandling() {
- try {
- Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
- } catch (Exception e1) {
- System.err.println("Got an exception! ");
- e1.printStackTrace();
- }
- }
- Boolean establishConnection(String _url, String _login, String _password) {
- String dbFeed = "jdbc:sybase:Tds:" + _url;
- try {
- conn = DriverManager.getConnection(dbFeed,_login,_password);
- } catch (Exception e2) {
- System.err.println("Got an exception! ");
- e2.printStackTrace();
- }
- return true;
- }
- void closeConnection() {
- try {
- conn.close();
- } catch (Exception e3) {
- System.err.println("Got an exception! ");
- e3.printStackTrace();
- }
- }
- ResultSet executeQuery(String _query) throws java.sql.SQLException {
- ResultSet rs = null;
- Statement stmt = null;
- try {
- stmt = conn.createStatement();
- rs = stmt.executeQuery(_query);
- } finally {
- stmt.close();
- }
- return rs;
- }
- }
Add Comment
Please, Sign In to add comment