Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DBConnection {
- private final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
- private String host;
- private String root;
- private String password;
- private String nameDb;
- private String url;
- private Properties properties = new Properties();
- private Connection connection;
- private PreparedStatement preparedStatement = null;
- public DBConnection(String host,String root,String password,String nameDb){
- this.host = host;
- this.root = root;
- this.password = password;
- this.nameDb = nameDb;
- }
- public DBConnection(String url,Properties properties){
- this.url = url;
- this.properties = properties;
- }
- public void iniProperties(){
- url = "jdbc:mysql://"+host+"/"+nameDb;
- }
- public void init(){
- if(connection == null) {
- try {
- Class.forName(JDBC_DRIVER);
- connection = DriverManager.getConnection(url + "?useSSL=false", root, password); // вот здесь ошибка
- } catch (SQLException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
- }
- public class Home_form extends javax.swing.JFrame {
- DBConnection connection = new DBConnection("192.168.194.115", "admin", "0000", "test_lessons");
- private String name_ = "";
- private String lastname_ = "";
- private String fathername_ = "";
- private String password_ = "";
- private String login_ = "";
- private java.util.List<String> List = new ArrayList<>();
- /**
- * Creates new form Home_form
- */
- public Home_form() {
- initComponents();
- acept.setVisible(false);
- name.setVisible(false);
- lastname.setVisible(false);
- fathername.setVisible(false);
- about.setVisible(false);
- jLabel3.setVisible(false);
- jLabel4.setVisible(false);
- jLabel5.setVisible(false);
- jLabel6.setVisible(false);
- connection.iniProperties();
- connection.init(); //ошибка
- at com.testing.DBConnection.init(DBConnection.java:41)
- at com.testing.Home_form.<init>(Home_form.java:48)
- at com.testing.Home_form$7.run(Home_form.java:338)
Add Comment
Please, Sign In to add comment