Script Sql ok avec oracle -> crash avec jdbc
salut tout le monde,
j'ai un léger soucis d'exécutions de script dans mon code Java en utilisant JDBC:
1. j'ai un script SQL qui crée une table
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| DECLARE
nb number(10) := 0;
BEGIN
SELECT count(*)
INTO nb
FROM user_tables
WHERE table_name = 'MA_TABLE_QUI_DEFONCE';
IF nb = 1 THEN
EXECUTE IMMEDIATE 'DROP TABLE MA_TABLE_QUI_DEFONCE';
END IF;
END;
.
RUN;
CREATE TABLE MA_TABLE_QUI_DEFONCE
(
name varchar2(250) NOT NULL,
type number(5) NOT NULL
) storage ( initial 128k next 128k pctincrease 0 maxextents unlimited ); |
2. j'essaye de l'exécuter dans mon code Java via cette methode
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
public static boolean executeDBScripts(String aSQLScriptFilePath, Statement stmt)
throws IOException, SQLException {
boolean isScriptExecuted = false;
try {
BufferedReader in = new BufferedReader(new FileReader(aSQLScriptFilePath));
String str;
StringBuffer sb = new StringBuffer();
while ((str = in.readLine()) != null) {
sb.append(str + "\n ");
}
in.close();
stmt.executeUpdate(sb.toString());
isScriptExecuted = true;
} catch (Exception e) {
System.err.println("Failed to Execute" + aSQLScriptFilePath + ". The error is" + e.getMessage());
}
return isScriptExecuted;
} |
3. ça crash à l'exécution alors qu'avec Oracle en faisant F5 ça marche très bien:
Failed to ExecutecreateTest.sql. The error isORA-06550: line 17, column 2:
PLS-00103: Encountered the symbol "."
4. vous pouvez m'aider ?