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.ResultSet;
- import java.sql.Statement;
- import java.util.Scanner;
- public class SQL
- {
- {
- String url = "jdbc:mysql://localhost:3306/";
- String user = "root";
- String password = "";
- try
- {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- Connection con = DriverManager.getConnection(url, user, password);
- Statement stt = con.createStatement();
- stt.execute("USE test");
- ResultSet res = stt.executeQuery("SELECT * FROM osoba WHERE nazwisko = 'nowak'");
- stt.execute("INSERT INTO osoba(imie, nazwisko, wiek, pesel) VALUES" +
- "('jan', 'nowak', 25, 99999)");
- res.close();
- stt.close();
- con.close();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- //------------------------------
- public void dodaj_osobe()
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement