Advertisement
Guest User

Untitled

a guest
May 30th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.SQLException;
  4. import java.sql.Statement;
  5.  
  6. public class Zad6 {
  7.  
  8. public static void main(String argv[]) {
  9.  
  10. Connection connection = otvoriKonekciju();
  11.  
  12. try {
  13. Statement stmt = connection.createStatement();
  14. stmt.executeUpdate("EXECUTE PROCEDURE rasporediPoGrupama()");
  15. System.out.println("Procedura je izvršena.");
  16. connection.close();
  17. }
  18. catch (SQLException exception) {
  19. System.out.println(exception.getErrorCode() + " " + exception.getMessage());
  20. }
  21. }
  22.  
  23. private static Connection otvoriKonekciju () {
  24. Connection conn = null;
  25. String url = "jdbc:informix-sqli://sbp.edu:1526/sbpdz2"
  26. + ":INFORMIXSERVER=sbp;DB_LOCALE=hr_hr.utf8;CLIENT_LOCALE=hr_hr.utf8;"
  27. + "user=horvat;password=horvat";
  28.  
  29. try {
  30. Class.forName("com.informix.jdbc.IfxDriver");
  31. System.out.println("Informix JDBC driver je uèitan i registriran.");
  32. } catch (ClassNotFoundException exception) {
  33. System.out.println("Pogreška: nije uspjelo uèitavanje Informix JDBC driver-a.");
  34. System.out.println(exception.getMessage());
  35. System.exit(-1);
  36. }
  37.  
  38. try {
  39. conn = DriverManager.getConnection(url);
  40. System.out.println("Konekcija je uspostavljena.");
  41. } catch (SQLException exception) {
  42. System.out.println("Pogreška: nije uspjelo uspostavljanje konekcije.");
  43. System.out.println(exception.getErrorCode() + " " + exception.getMessage());
  44. System.exit(-1);
  45. }
  46. return conn;
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement