Guest User

Untitled

a guest
Oct 27th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. public class DBConnection {
  2. private final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
  3. private String host;
  4. private String root;
  5. private String password;
  6. private String nameDb;
  7. private String url;
  8. private Properties properties = new Properties();
  9. private Connection connection;
  10. private PreparedStatement preparedStatement = null;
  11.  
  12. public DBConnection(String host,String root,String password,String nameDb){
  13. this.host = host;
  14. this.root = root;
  15. this.password = password;
  16. this.nameDb = nameDb;
  17.  
  18. }
  19.  
  20. public DBConnection(String url,Properties properties){
  21. this.url = url;
  22. this.properties = properties;
  23. }
  24.  
  25. public void iniProperties(){
  26. url = "jdbc:mysql://"+host+"/"+nameDb;
  27.  
  28. }
  29.  
  30. public void init(){
  31. if(connection == null) {
  32. try {
  33. Class.forName(JDBC_DRIVER);
  34. connection = DriverManager.getConnection(url + "?useSSL=false", root, password); // вот здесь ошибка
  35. } catch (SQLException e) {
  36. e.printStackTrace();
  37. } catch (ClassNotFoundException e) {
  38. e.printStackTrace();
  39. }
  40. }
  41. }
  42.  
  43. public class Home_form extends javax.swing.JFrame {
  44. DBConnection connection = new DBConnection("192.168.194.115", "admin", "0000", "test_lessons");
  45. private String name_ = "";
  46. private String lastname_ = "";
  47. private String fathername_ = "";
  48. private String password_ = "";
  49. private String login_ = "";
  50. private java.util.List<String> List = new ArrayList<>();
  51.  
  52.  
  53.  
  54. /**
  55. * Creates new form Home_form
  56. */
  57. public Home_form() {
  58. initComponents();
  59. acept.setVisible(false);
  60. name.setVisible(false);
  61. lastname.setVisible(false);
  62. fathername.setVisible(false);
  63. about.setVisible(false);
  64. jLabel3.setVisible(false);
  65. jLabel4.setVisible(false);
  66. jLabel5.setVisible(false);
  67. jLabel6.setVisible(false);
  68. connection.iniProperties();
  69. connection.init(); //ошибка
  70.  
  71. at com.testing.DBConnection.init(DBConnection.java:41)
  72. at com.testing.Home_form.<init>(Home_form.java:48)
  73. at com.testing.Home_form$7.run(Home_form.java:338)
Add Comment
Please, Sign In to add comment