Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Matr. 093102
Introduzione
La Base di Dati riguarda un consorzio di allevamento di bestiame. Quest'ultimo utilizza la Base di Dati
per avere una panoramica generale dell’azienda per quanto riguarda l’aspetto dei suoi impiegati, i dati
riferiti agli allevamenti, le loro effettive quantità prodotte, il magazzino per il deposito del prodotto e le
vendite ai clienti.
Disponendo anche di strutture per il deposito del prodotto, le quali sono rappresentate come unita che
eseguono gli scambi delle merci.
I clienti che acquistano dal deposito, sono individuati nella Base di Dati mediante la partita IVA.
Raccolta Informazioni
Informazioni riguardanti il consorzio e la fornitura di carne ai clienti.
• La società dispone di un certo numero di allevamenti che hanno un nome distinto, un indirizzo, capienza
massima di bestie, dimensione (in metri quadrati).
• Ogni allevamento ha un gruppo di lavoratori i quali hanno una data inizio lavoro presso l'allevamento.
Gli allevatori sono di diverse qualifiche come: addetti alla stalla, addetti alla salute delle bestie, al
mangime, al pascolo etc.
• Gli impiegati dei magazzini si distinguono dall’attributo Ruolo. Abbiamo supposto che anche la
direzione fosse stabilita dentro i magazzini come le segretarie, i ragionieri etc.
• Gli impiegati hanno le seguenti informazioni: Codice Fiscale (che gli identifica), Nome, Cognome, Data
di Nascita, Anno assunzione, Stipendio, Sesso, Indirizzo, Numero di Telefono.
• La società ha un certo numero di magazzini i quali sono distinti attraverso un Codice identificativo
univoco. Ogni magazzino ha: Nome, Città, Indirizzo, Numero di Telefono, una capienza massima.
• Un allevamento fornisce a più magazzini, quest'ultimi possono essere forniti da diversi allevamenti.
NB: Non si può scaricare più carne dell’effettivo spazio in magazzino.
• Inoltre il consorzio fornisce i suoi prodotti al pubblico. Dei clienti si possiedono le seguenti
informazioni: nome, indirizzo, partita IVA, numero telefono.
• Per ogni cliente, viene registrata la quantità di carne per ogni tipo, il prezzo e la data dell'acquisto.
Progettazione Concettuale
Applicando un approccio di tipo BOTTOM-UP, TOP-DOWN(mista) si evidenziano delle prime entità
principali come:
• IMPIEGATO
• ALLEVAMENTO
• CARNE
• CLIENTE
• Primo raffinamento
Dalle specifiche del progetto, l’introduzione di una gerarchia di specializzazione che evidenzia i concetti:
Un' ulteriore struttura gerarchica e quella che distingue gli impiegati che lavorano nell'allevamento :
• VETERINARIO
• ALLEVATORE
L’entità CARNE è un’entità debole la quale è messa in relazione con MAGAZZINO mediante
l’associazione SCARICA_IN. Risulta debole perchè non esiste un insieme di attributi chiave e si
presentato molte tuple ripetute.
• Terzo raffinamento
Si effettua un nuovo raffinamento quando si vuole esprimere (presente nelle specifiche del progetto) la
relazione che c’è tra magazzino e cliente, partendo dalla richiesta di rappresentare le quantità di carne
ritirate, la data del ritiro e il prezzo. Così si presenta lo schema dopo un successivo raffinamento.
FORNITURA_TIPO
MAGAZZINO
PRENDE
LOCALE
OFFRE
Alla fine introducendo anche gli attributi sulle entità e sulle associazioni avremo lo schema
finale ER Esteso:
Ristrutturazione
La fase di ristrutturazione dello schema E-R esteso consiste nella:
Consiste nel rimuovere la struttura di specializzazione / generalizzazione che è creata nella posizione
dell’entità IMPIEGATO:
L’eliminazione delle specializzazioni non comporta l’introduzione di ridondanze per il fatto che soltanto
due attributi caratterizzano le particolari entità specializzanti quindi introduciamo soltanto un campo per il
quale possono verificarsi valori nulli.
L'eliminazione della generalizzazione IMPIEGATO inizialmente può sembrare sbagliata perché
ripetiamo gli stessi campi per due entità. Se facciamo riferimento alle esigenze del sistema informativo, si
vede che non sono frequenti le query sui dati degli impiegati essendo più legati alla parte finanziaria della
società. Ci verrà più utile avere dei dati separati per i due tipi d’impiegati.
Nel nostro schema abbiamo soltanto un’entità debole, l’entità CARNE. La rimozione dell’entità debole
consiste nell’accorpare all’insieme degli attributi anche gli attributi che costituiscono la chiave dell’entità
ALLEVAMENTO che è anche entità dominante. Così individuando come chiave dell’entità CARNE
l’insieme dei due attributi: NomeAllev, DataProd, TipoCarne.
• Per quanto riguarda Dati_Allev nell’entità ALLEVAMENTO ho preferito inserire dei nuovi attributi
semplici che indicano i dati sullo specifico allevamento. Quest'ultimi Dati sono importanti per le
interrogazioni da parte dell’azienda.
4- L’entità FORNITURA_TIPO è stata tradotta come una relazione identificata esternamente dalle
chiavi di magazzino e cliente (PIVA e Cod_Magazzino). La relazione finale avrà come chiave gli
identificatori esterni insieme con TipoCarne e Data. Quest'ultimo attributo rappresenta quando è stata
effettuata la fornitura. Cosi si rappresenterà alla fine la relazione FORNITURA_TIPO :
2NF: SI perchè la chiave primaria è composta di un solo attributo (non possono esserci
dipendenze funzionali parziali).
3NF: NO perchè esiste la DF {Ruolo, Anno_Assunzione}→{Stipendio} che Stipendio è un attributo non-
primo e Ruolo, Anno_Assunzione non sono superchiave della relazione.
2NF: SI perchè la chiave primaria è composta di un solo attributo (non possono esserci
dipendenze funzionali parziali).
3NF: NO perchè esiste la DF {Professione, Anno_Assunzione}→{Stipendio} che Stipendio è un
attributo non-primo e Professione, Anno_Assunzione non sono una superchiave.
2NF: SI perchè la chiave primaria è composta di un solo attributo (non possono esserci
dipendenze funzionali parziali).
3NF: SI perchè tute le DF hanno la parte determinante una superchiave.
2NF: SI perchè la chiave primaria è composta di un solo attributo (non possono esserci
dipendenze funzionali parziali).
3NF: NO perché esiste la DF {Città, Nome} → {Indirizzo} ecc.
2NF: SI perchè la chiave primaria è composta di un solo attributo (non possono esserci
dipendenze funzionali parziali).
3NF: SI perché esiste l'insieme di attributi{Nome, Indirizzo} che è chiave candidata per la relazione.
Quindi tutte le DF hanno parte determinate una superchiave.
Progettazione fisica
La progettazione fisica della Base di Dati verrà scritta in Java attraverso il connettore per database JDBC,
che consente l'accesso alla base di dati in Oracle.
Segue il codice delle tabelle, compilato ed eseguito.
import java.sql.*;
Connection con;
String createString;
createString = "create table ALLEVA " +
"(NOMEALLEV varchar(30), " +
"STAGIONE varchar(8), " +
"MANGIME varchar(12), "+
"TIPOCARNE varchar(20))";
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
import java.sql.*;
Connection con;
String createString;
createString = "create table ALLEVAMENTO " +
"(NOME varchar(16) PRIMARY KEY, " +
"CAPIENZA_MAX int, " +
"DIM int, " +
"INDIRIZZO varchar(30))";
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
import java.sql.*;
Connection con;
String createString;
createString = "create table BESTIA " +
"(TIPOCARNE varchar(20), " +
"STAGIONE varchar(11), "+
"MANGIME varchar(12))";
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
import java.sql.*;
Connection con;
String createString;
createString = "create table CARNE " +
"(QUANTITA int, " +
"TIPOCARNE varchar(15), " +
"DATAPROD date, " +
"NOMEALLEV varchar(30), " +
"COD_MAGAZZINO char(5))";
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
import java.sql.*;
Connection con;
String createString;
createString = "create table CLIENTE " +
"(PIVA char(11) PRIMARY KEY, " +
"NOME varchar(15), " +
"TEL varchar(20), "+
"INDIRIZZO varchar(30))";
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
import java.sql.*;
Connection con;
String createString;
createString = "create table FORNITURATIPO " +
"(DATA date, " +
"TIPOCARNE varchar(20), " +
"PREZZO float, " +
"QUANTITA int, " +
"PIVA_CLIENTE char(11), "+
"COD_MAGAZZINO char(5))";
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
import java.sql.*;
public class CreateImpAllev {
Connection con;
String createString;
createString = "create table IMP_ALLEV " +
"(CF char(16) PRIMARY KEY, " + "NOME varchar(15), " + "COGNOME varchar(15) , "
+
"PROFESSIONE varchar(20), " + "SPECIALIZZAZIONE varchar(20), " +
"NTEL varchar(20), " + "STIPENDIO int, " + "NOMEALLEV varchar(30), " +
"INDIRIZZO varchar(30), " + "ANNO_ASSUNZ date, " +
"SESSO char(1), " + "DATA_INIZIO date)";
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
import java.sql.*;
Connection con;
String createString;
createString = "create table IMP_MAGAZZINO " +
"(CF char(16) PRIMARY KEY, " + "COD_MAG char(5), " + "NOME varchar(15) NOT
NULL, " +
"COGNOME varchar(15) NOT NULL, " + "NTEL varchar(20) DEFAULT 'non
disponibile', " + "STIPENDIO int DEFAULT NULL, " +
"INDIRIZZO varchar(30), " + "SESSO char(1), " + "RUOLO varchar(30), " +
"ANNO_ASSUNZIONE date) ";
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
import java.sql.*;
Connection con;
String createString;
createString = "create table MAGAZZINO " +
"(COD_MAGAZZINO char(5) PRIMARY KEY, " +
"CITTA varchar(15), " +
"NOME varchar(15), " +
"TEL varchar(20), " +
"CAPIENZA int, " +
"INDIRIZZO varchar(20), " +
"MOD_PAGAMENTO varchar(10))";
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
import java.sql.*;
Connection con;
Statement stmt;
String query = "select NOMEALLEV, TIPOCARNE from ALLEVA";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
stmt.executeUpdate("insert into ALLEVA " +
"values('Lallevamento spa', 'inverno', 'erba','manzo')");
ResultSet rs = stmt.executeQuery(query);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
import java.sql.*;
Connection con;
Statement stmt;
String query = "select TIPOCARNE, STAGIONE from BESTIA";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
System.out.println("TIPOCARNE e STAGIONE:");
while (rs.next()) {
String s = rs.getString("TIPOCARNE");
String f = rs.getString("STAGIONE");
System.out.println(s + " " + f);
}
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
import java.sql.*;
Connection con;
Statement stmt;
String query = "select TIPOCARNE, NOMEALLEV from CARNE";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
stmt.close();
con.close();
} catch(SQLException ex)
{
System.err.println("SQLException: " + ex.getMessage());
}
}
}
import java.sql.*;
Connection con;
Statement stmt;
String query = "select DATA, TIPOCARNE, PIVA_CLIENTE from FORNITURATIPO";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
import java.sql.*;
Connection con;
Statement stmt;
String query = "select NOME, COGNOME, NOMEALLEV from IMP_ALLEV";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
import java.sql.*;
Connection con;
Statement stmt;
String query = "select NOME, COGNOME, RUOLO from IMP_MAGAZZINO";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
import java.sql.*;
Connection con;
Statement stmt;
String query = "select NOME, MOD_PAGAMENTO from MAGAZZINO";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
import java.sql.*;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
System.out.println(": ");
while (rs.next()) {
int n = rs.getInt("QUANTITA");
System.out.println("la quantita' di carne comprata dall'allevamento in via
Bologna a Malo è " + n);
}
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.print("SQLException: ");
System.err.println(ex.getMessage());
}
}
}
import java.sql.*;
Connection con;
String query = "select IMP_MAGAZZINO.NOME " +
"from IMP_MAGAZZINO, MAGAZZINO " +
"where MAGAZZINO.CITTA like 'Ferrara' and " +
"MAGAZZINO.COD_MAGAZZINO = IMP_MAGAZZINO.COD_MAG";
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
System.out.println(": ");
while (rs.next()) {
String nome = rs.getString("NOME");
System.out.println(" " + nome);
}
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.print("SQLException: ");
System.err.println(ex.getMessage());
}
}
}
import java.sql.*;
Connection con;
String query = "select ALLEVA.NOMEALLEV, BESTIA.MANGIME " +
"from BESTIA, ALLEVA " +
"where ALLEVA.NOMEALLEV like 'Lallevamento spa' " +
"and ALLEVA.TIPOCARNE = BESTIA.TIPOCARNE ";
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
System.out.println(": ");
while (rs.next()) {
String nome = rs.getString("MANGIME");
System.out.println(" " + nome);
stmt.close();
con.close();
}}
catch(SQLException ex) {
System.err.print("SQLException: ");
System.err.println(ex.getMessage());
}
}
import java.sql.*;
Connection con;
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
srs.absolute(1);
System.out.println("after last? " + srs.isAfterLast() );
if (!srs.isAfterLast()) {
String name = srs.getString("NOME");
String city =srs.getString("CITTA");
System.out.println(name + " " + city);
}
srs.close();
stmt.close();
con.close();
} catch(BatchUpdateException b) {
System.err.println("-----BatchUpdateException-----");
System.err.println("SQLState: " + b.getSQLState());
System.err.println("Message: " + b.getMessage());
System.err.println("Vendor: " + b.getErrorCode());
System.err.print("Update counts: ");
int [] updateCounts = b.getUpdateCounts();
for (int i = 0; i < updateCounts.length; i++) {
System.err.print(updateCounts[i] + " ");
}
System.out.println("");
} catch(SQLException ex) {
System.err.println("-----SQLException-----");
System.err.println("SQLState: " + ex.getSQLState());
System.err.println("Message: " + ex.getMessage());
System.err.println("Vendor: " + ex.getErrorCode());
}
}
}
import java.sql.*;
Connection con;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(java.lang.ClassNotFoundException e)
{
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
con.setAutoCommit(false);
//in una grande quantita' di un ordine abbassare il prezzo, selezionando il tipo di
carne
String query = "select CODMAGAZZINO from FORNITURATIPO " +
" where TIPOCARNE = ? ";
String update = "UPDATE FORNITURATIPO SET PREZZO = ? " +
" WHERE CODMAGAZZINO = ? ";
getQuantita.setString(1 , "manzo");
//qui c'è l'errore
ResultSet rs = getQuantita.executeQuery();
while (rs.next())
{
String codmagazzino = rs.getString("CODMAGAZZINO");
float oldPrice = rs.getFloat("PREZZO");
float newPrice = oldPrice + (oldPrice - 10);
updateQuantita.setFloat(1, newPrice);
updateQuantita.setString(2, codmagazzino);
updateQuantita.executeUpdate();
System.out.println("il nuovo prezzo dell'ordine al magazzino" + codmagazzino + "
e' " +
newPrice);
if (newPrice < 1000) {
con.rollback(save1);
}
con.commit();
System.out.println();
while (rs.next()) {
String carne = rs.getString("TIPOCARNE");
float price = rs.getFloat("PREZZO");
System.out.println("Current price of " + carne +
" is " + price);
}
con.commit();
con.close();
} catch (Exception e) {
e.printStackTrace();
}
}}
import java.sql.*;
Connection con;
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
System.out.println(p_iva + " " + name + " " + tel + " " + indirizzo);
}
srs.close();
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("-----SQLException-----");
System.err.println("SQLState: " + ex.getSQLState());
System.err.println("Message: " + ex.getMessage());
System.err.println("Vendor: " + ex.getErrorCode());
}
}
}
import java.sql.*;
ResultSet rs = null;
PreparedStatement ps = null;
Connection con;
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
con.setAutoCommit(false);
stmt = con.createStatement();
uprs.close();
stmt.close();
con.close();
} catch(BatchUpdateException b) {
System.err.println("-----BatchUpdateException-----");
System.err.println("SQLState: " + b.getSQLState());
System.err.println("Message: " + b.getMessage());
System.err.println("Vendor: " + b.getErrorCode());
System.err.print("Update counts: ");
int [] updateCounts = b.getUpdateCounts();
for (int i = 0; i < updateCounts.length; i++) {
System.err.print(updateCounts[i] + " ");
}
System.err.println("");
} catch(SQLException ex) {
System.err.println("-----SQLException-----");
System.err.println("SQLState: " + ex.getSQLState());
System.err.println("Message: " + ex.getMessage());
System.err.println("Vendor: " + ex.getErrorCode());
}
}
}
import java.sql.*;
ResultSet rs = null;
PreparedStatement ps = null;
Connection con;
Statement stmt;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"SYSTEM","080984");
con.setAutoCommit(false);
stmt = con.createStatement();
uprs.close();
stmt.close();
con.close();
} catch(BatchUpdateException b) {
System.err.println("-----BatchUpdateException-----");
System.err.println("SQLState: " + b.getSQLState());
System.err.println("Message: " + b.getMessage());
System.err.println("Vendor: " + b.getErrorCode());
System.err.print("Update counts: ");
int [] updateCounts = b.getUpdateCounts();
for (int i = 0; i < updateCounts.length; i++) {
System.err.print(updateCounts[i] + " ");
}
System.err.println("");
} catch(SQLException ex) {
System.err.println("-----SQLException-----");
System.err.println("SQLState: " + ex.getSQLState());
System.err.println("Message: " + ex.getMessage());
System.err.println("Vendor: " + ex.getErrorCode());
}
}
}