|
Muhammad Al-Xorazmiy nomidagi Toshkent axborot texnologiya universiteti
|
bet | 3/4 | Sana | 07.01.2024 | Hajmi | 53,53 Kb. | | #131436 |
Bog'liq 13LabConnection connection = null;
Statement statement = null;
try {
System.out.println("JDBC drayverni ro'yxatdan o'tkazish...");
Class.forName(JDBC_DRIVER);
System.out.println("Ma'lumotlar bazasiga bog'lanish...");
connection = DriverManager.getConnection(DATABASE_URL, USER, PASSWORD);
System.out.println("Tanlangan ma'lumotlar bazasida jadval yaratish...");
statement = connection.createStatement();
String SQL = "CREATE TABLE dasturchilar "
+ "(id INTEGER not NULL, "
+ " name VARCHAR(50), "
+ " specialty VARCHAR (50), "
+ " salary INTEGER not NULL, "
+ " PRIMARY KEY (id))";
statement.executeUpdate(SQL);
System.out.println("Jadval muvaffaqiyatli yaratildi...");
} finally {
if (statement != null) {
statement.close();
}
if (connection != null) {
connection.close();
}
}
}
}
Dastur natijasi : 13.2
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package laboratoriya_13;
import java.sql.*;
public class InsertRecord {
static final String DATABASE_URL = "jdbc:mysql://localhost/boymatov_elbek";
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String USER = "root";
static final String PASSWORD = "admin";
public static void main(String[] args) throws ClassNotFoundException, SQLException {
Connection connection = null;
|
| |