Advertisement
Guest User

Untitled

a guest
Mar 7th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import com.mysql.fabric.jdbc.FabricMySQLDriver;
  2. import java.sql.*;
  3.  
  4. /**
  5. * Created by taras on 07.03.2016.
  6. */
  7. public class Main {
  8. private static final String URL = "jdbc:mysql://localhost:3306/library";
  9. private static final String USER = "root";
  10. private static final String PASSWORD = "root";
  11.  
  12.  
  13. public static void main(String[] args){
  14. try {
  15. Driver driver = new FabricMySQLDriver();
  16. DriverManager.registerDriver(driver);
  17. } catch (SQLException e) {
  18. e.printStackTrace();
  19. }
  20.  
  21. try (Connection connection = DriverManager.getConnection(URL,USER,PASSWORD ); Statement statement = connection.createStatement() ){
  22. statement.execute("INSERT INTO library.country (country_id, name, capital) VALUES ('8', 'США', 'Вашингтон');");
  23. }catch (SQLException e) {
  24. e.printStackTrace();
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement