Biblioteca Java - Blame information for rev 35

Subversion Repositories:
Rev:
Rev Author Line No. Line
3 mihai 1 /*
2  * TestAdaugaTabel.java
3  */
4 package lab.scd.db.jdbc10;
5  
6 import java.sql.Connection;
7 import java.sql.DriverManager;
8 import java.sql.Statement;
9  
10 import lab.scd.db.util.DBConfig;
11  
12 /**
13  * Class created by @author Mihai HULEA at Mar 10, 2005.
35 mihai 14  *
3 mihai 15  * This class is part of the laborator4_db project.
35 mihai 16  *
3 mihai 17  */
18 public class TestAdaugaTabel {
19  
20     public static void main(String[] args) {
35 mihai 21         try {
22             Class.forName("org.apache.derby.jdbc.ClientDriver");
23  
24             //conectare la baza de date
25             Connection conn = DriverManager.getConnection("jdbc:derby://" + DBConfig.HOST + "/" + DBConfig.DATABASE, DBConfig.USER, DBConfig.PWD);
26             System.out.println("Conexiune la baza de date realizata.");
27  
28             /**
29              * Pentru a efectua iperatii asupra bazei de date este nevoie de un
30              * obiect de tip Statement.
31              */
32             Statement stat = conn.createStatement();
33  
34             //aduaga tabelul stoc cu doua campuri (prod si pret)
35             stat.executeUpdate("CREATE TABLE STOC (PROD VARCHAR(32), PRET INTEGER)");
36             System.out.println("Tabel creat.");
37  
38             //adauga doua produse in tabel
39             stat.executeUpdate("INSERT INTO STOC VALUES ('produs 1' , 2500)");
40             stat.executeUpdate("INSERT INTO STOC VALUES ('produs 2' , 7900)");
41  
42             System.out.println("Date inserate in tabel.");
43  
44             conn.close();
45         } catch (Exception e) {
3 mihai 46             e.printStackTrace();
47         }
35 mihai 48     }
3 mihai 49 }