Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- System.out.println("MySQL Connect Example.");
- // Connection conn = null;
- // String url = "jdbc:mysql://127.0.0.1:3306/";
- // String dbName = "test";
- // String driver = "com.mysql.jdbc.Driver";
- // String userName = "root";
- // String password = "root";
- // try {
- // Class.forName(driver).newInstance();
- // conn = DriverManager.getConnection(url + dbName, userName, password);
- // System.out.println("Connected to the database");
- //
- // try {
- //// Statement st = conn.createStatement();
- //// int val = st.executeUpdate("INSERT INTO Korisnik (Ime, Prezime) VALUES('','');");
- // preparedStatement = conn.prepareStatement("INSERT INTO Korisnik (Ime, Prezime) VALUES ( ?, ?)");
- // preparedStatement.setString(1, Ime_tf.getText());
- // preparedStatement.setString(2, Prezime_tf.getText());
- // preparedStatement.executeUpdate();
- // System.out.println("1 row affected");
- // } catch (SQLException s) {
- // s.printStackTrace();
- // System.out.println("SQL statement is not executed!");
- // }
- //
- // conn.close();
- // System.out.println("Disconnected from database");
- // } catch (Exception e) {
- // e.printStackTrace();
- // }
Add Comment
Please, Sign In to add comment