• System.out.println("Malumotlar bazasiga boglanish..."); connection = DriverManager.getConnection(DATABASE_URL, USER, PASSWORD);
  • Dastur natijasi : 13.1 Dastur kodi : 13.2 /* * To change this license header, choose License Headers in Project Properties.
  • static final String PASSWORD = "admin"




    Download 53,53 Kb.
    bet2/4
    Sana07.01.2024
    Hajmi53,53 Kb.
    #131436
    1   2   3   4
    Bog'liq
    13Lab

    static 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 natijasi : 13.1



    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 {

    Download 53,53 Kb.
    1   2   3   4




    Download 53,53 Kb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    static final String PASSWORD = "admin"

    Download 53,53 Kb.