|
static final String PASSWORD = "admin"
|
bet | 2/4 | Sana | 07.01.2024 | Hajmi | 53,53 Kb. | | #131436 |
Bog'liq 13Labstatic final String PASSWORD = "admin";
public static void main(String[] args) throws ClassNotFoundException, SQLException {
Connection 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("Ma'lumotlar bazasini yaratish...");
statement = connection.createStatement();
String SQL = "CREATE DATABASE boymatov_elbek";
statement.executeUpdate(SQL);
System.out.println("Ma'lumotlar bazasi muvaffaqiyatli yaratildi...");
}
finally {
if(statement!=null){
statement.close();
}
if(connection!=null){
connection.close();
}
}
}
}
Dastur kodi : 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.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class CreateTable {
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 {
|
| |