create database SampleDB;
use SampleDB;
CREATE TABLE product (
product_id Number NOT NULL AUTO_INCREMENT,
productname varchar(45) NOT NULL,
Quality number NOT NULL,
Price decimal NOT NULL,
model varchar(45) NOT NULL,
description varchar(245) NOT NULL,
PRIMARY KEY (product_id)
);
//STEP 1. Import required packages
import java.sql.*;
public class JDBCExample {
// JDBC driver name and database URL
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:oracle://localhost/products";
// Database credentials
static final String USER = "username";
static final String PASS = "password";
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
try{
//STEP 2: Register JDBC driver
Class.forName("com.mysql.jdbc.Driver");
//STEP 3: Open a connection
System.out.println("Connecting to a selected database...");
conn = DriverManager.getConnection(DB_URL, USER, PASS);
System.out.println("Connected database successfully...");
//STEP 4: Execute a query
System.out.println("Inserting records into the table...");
stmt = conn.createStatement();
String sql = "INSERT INTO Products " +
"VALUES (100, 'Mobile 2', 1, 1800, 's7', 'Its a good pfone')";
stmt.executeUpdate(sql);
System.out.println("Inserted records into the table...");
}catch(SQLException se){
//Handle errors for JDBC
se.printStackTrace();
}catch(Exception e){
//Handle errors for Class.forName
e.printStackTrace();
}finally{
//finally block used to close resources
try{
if(stmt!=null)
conn.close();
}catch(SQLException se){
}// do nothing
try{
if(conn!=null)
conn.close();
}catch(SQLException se){
se.printStackTrace();
}//end finally try
}//end try
System.out.println("Goodbye!");
}//end main
}//end JDBCExample
5AEBC7F17D
ReplyDeleteyeni çıkan mmorpg oyunlar
sms onay
turkcell mobil ödeme bozdurma
takipci satin alma
-
C347AAC993
ReplyDeletekiralık hacker
kiralık hacker arıyorum
kiralık hacker
hacker arıyorum
kiralık hacker
B1E9C1CEF1
ReplyDeleteTakipçi Satın Al
20 Abone Hilesi
1K Bot Takipçi Ücretsiz
500 Abone Hilesi Ücretsiz
1000 Takipçi Hilesi Bedava Tiktok
Tiktok 1000 Beğeni Hilesi Ücretsiz
Youtube 1000 Abone Kasma Bedava
Instagram Video İzlenme Hilesi 1000 Şifresiz
Tiktok Beğeni Hilesi Şifresiz En İyi 100 Çalışan