Zbekiston respublikasi axborot texnologiyalari va




Download 0,88 Mb.
Pdf ko'rish
bet2/2
Sana08.01.2024
Hajmi0,88 Mb.
#132530
1   2
Bog'liq
13-Laboratoriya ishi
1-topshiriq (1), Axborot xavfsizligida risklarni boshqarish jarayonining tahlili. Mustaqil ish, 01 488 LBA давлат рақамли УАЗ 315148-095, Oziq-ovqat va qishloq xo\'jaligini tashkil etish BMT, Тошпўлатов Хуршид Абдурахим ўғли, Замчалова (2), 1, Янги Ўзбекистон 00, Jo‘ramirzayev G‘ulomqodir AMALIY ISHI, Doira” klassini yarating. Maydoni aylana radiusi (R). Virtual m-fayllar.org, 7-labaratoriya ishiga javoblari Labaratoriya ishi – 7-fayllar.org, O’zbekiston respublikasi qurilish vazirligi toshkent arxitektura-fayllar.org, II - chorak. 10 sinf Algebra 3 - BSB original I - variant, Maktab kutubxonalari fondini shakllantirish va butlash, 18А-Т
Dastur kodi 
/* 
* 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 CreateDB { 
static final String DATABASE_URL = "jdbc:mysql://localhost/"; 
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver"; static 
final String USER = "root"; 
static final String PASSWORD = "admin"; 
ublic 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 
qodir_habibullayev"; statement.executeUpdate(SQL); 


System.out.println("Ma'lumotlar bazasi 
muvaffaqiyatli yaratildi..."); 

finally { 
if(statement!=null){ 
statement.close(); 

if(connection!=null){ 
connection.close(); 



/* 
* 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/qodir_habibullayev"; 
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver"; 
tatic final String USER = "root"; 
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("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(); 






/* 
* 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/qodir_habibullayev"; 
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; 
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("Yozuvlarni qo'shish..."); 
statement = connection.createStatement(); 
String SQL = "INSERT into dasturchilar VALUE (1, 
'Qodir Khabibullayev', 'Frontend Developer', 1000)"; 
tatement.executeUpdate(SQL); 
SQL = "INSERT into dasturchilar VALUE (2, 'Sherzod 
Pirmatov', 'Backend Developer', 2500)"; 
statement.executeUpdate(SQL); 
SQL = "INSERT into dasturchilar VALUE (3, 'Aliyev 
Vali', 'Mobile Developer', 2000)"; 
statement.executeUpdate(SQL); 
SQL = "INSERT into dasturchilar VALUE (4, 'Sarvar 
Karimov', 'Frontend Developer', 1000)"; 
statement.executeUpdate(SQL); 
} finally { 
if (statement != null) { 


statement.close(); 

if (connection != null) { 
connection.close(); 






Kod natijasi 
 


 

Download 0,88 Mb.
1   2




Download 0,88 Mb.
Pdf ko'rish

Bosh sahifa
Aloqalar

    Bosh sahifa



Zbekiston respublikasi axborot texnologiyalari va

Download 0,88 Mb.
Pdf ko'rish