Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Connection connection;
- public void ucitajDriver() throws Exception {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- } catch (ClassNotFoundException ex) {
- throw new Exception("Neuspesno ucitavanje drivera!", ex);
- }
- }
- public void otvoriKonekciju() throws Exception {
- try {
- connection = DriverManager.getConnection("jdbc:mysql://localhost/poslovnipartneri", "root", "");
- connection.setAutoCommit(false);
- // Zahteva eksplicitnu potvrdu transakcije
- } catch (SQLException ex) {
- throw new Exception("Neuspesno otvaranje konekcije!", ex);
- }
- }
- public void commitTransakcije() throws Exception {
- try {
- connection.commit();
- } catch (SQLException ex) {
- throw new Exception("Neuspesan commit transakcije!", ex);
- }
- }
- public void rollbackTransakcije() throws Exception {
- try {
- connection.rollback();
- } catch (SQLException ex) {
- throw new Exception("Neuspesan rollback transakcije!", ex);
- }
- }
- public void zatvoriKonekciju() throws Exception {
- try {
- connection.close();
- } catch (SQLException ex) {
- throw new Exception("Neuspesno zatvaranje konekcije!", ex);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement