0% found this document useful (0 votes)
25 views2 pages

Ajp 18

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Ajp 18

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

package jdbc1;

import java.sql.*;

public class sauravzure {

public static void main(String[] args) throws ClassNotFoundException {

try {

// Replace with your database URL, username, and password

String url = "jdbc:mysql://localhost:3306/your_database";

String username = "your_username";

String password = "your_password";

// Load the JDBC driver

Class.forName("com.mysql.cj.jdbc.Driver");

// Establish a connection to the database

Connection connection =
DriverManager.getConnection("jdbc:mysql://localhost:3306/pandurang","root","root3112");

// Create a statement object

Statement statement = connection.createStatement();

// Create the table

String sql = "CREATE TABLE employees (" +

"emp_id INT PRIMARY KEY," +

"emp_name VARCHAR(50) NOT NULL" +

")";

statement.executeUpdate(sql);

System.out.println("Table created successfully!");


// Close the connection

statement.close();

connection.close();

} catch (SQLException e) {

e.printStackTrace();

You might also like