• System.out.println("Tanlangan malumotlar bazasida jadval yaratish..."); statement = connection.createStatement(); String SQL = "CREATE TABLE dasturchilar "
  • Dastur kodi : 13.3 /* * To change this license header, choose License Headers in Project Properties.
  • Muhammad Al-Xorazmiy nomidagi Toshkent axborot texnologiya universiteti




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

    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("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


    Dastur kodi : 13.3

    /*
    * 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;

    Download 53,53 Kb.
    1   2   3   4




    Download 53,53 Kb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Muhammad Al-Xorazmiy nomidagi Toshkent axborot texnologiya universiteti

    Download 53,53 Kb.