Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.mysql.fabric.jdbc.FabricMySQLDriver;
- import java.sql.*;
- /**
- * Created by taras on 07.03.2016.
- */
- public class Main {
- private static final String URL = "jdbc:mysql://localhost:3306/library";
- private static final String USER = "root";
- private static final String PASSWORD = "root";
- public static void main(String[] args){
- try {
- Driver driver = new FabricMySQLDriver();
- DriverManager.registerDriver(driver);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- try (Connection connection = DriverManager.getConnection(URL,USER,PASSWORD ); Statement statement = connection.createStatement() ){
- statement.execute("INSERT INTO library.country (country_id, name, capital) VALUES ('8', 'США', 'Вашингтон');");
- }catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement