Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mysql;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class MainApp {
- private static final String CREATE_TABLE_QUERY=
- "CREATE TABLE java_table(id INT AUTO_INCREMENT, java_text VARCHAR(400) UNIQUE," +
- " PRIMARY KEY(id))";
- public static void main(String[] args){
- try(Connection connection = getConnection();
- Statement statement = connection.createStatement();){
- statement.execute(CREATE_TABLE_QUERY);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- private static Connection getConnection() throws SQLException {
- return DriverManager.getConnection("jdbc:mysql://localhost:3306/mysqlbase",
- "root","root");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement