Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author Patryk
- */
- public class MySQLDatabase {
- public static void connection()
- {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- } catch (ClassNotFoundException e){
- e.printStackTrace();
- }
- }
- public static void connectionMySQL(){
- connection();
- String host = "jdbc:mysql://localhost/users";
- String username = "root";
- String password = "";
- PreparedStatement zapytanieMySQL = null; //Sprawdzic co to jest
- //ResultSet wynik = null;
- try {
- Connection polaczenie = DriverManager.getConnection(host, username, password);
- zapytanieMySQL = polaczenie.prepareStatement("Insert into users (Login, Password) value (?,?)");
- zapytanieMySQL.setString(1, "Jakubian");
- zapytanieMySQL.setString(2, "Superowatosci");
- System.out.println("Works :) ");
- zapytanieMySQL.execute();
- } catch (SQLException e){
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement