Bonjour,

J'ai un petit problème en voulant insérer une ligne dans ma table via JDBC que je n'arrive pas à m'expliquer.

J'ai le code suivant:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
public void test() {
		try {
			query = "INSERT INTO real_estates (id_real_estate, id_person, to_rent, to_sell, surface, price_for_buying, price_for_renting, available, " +
					"nb_of_rooms, date_of_publication, date_of_availability) VALUES ((SELECT MAX(id_real_estate) + 1 FROM real_estates), " +
					"(SELECT MAX(id_person) FROM owners), 0 ,1, '95', '150000', '0', 1, '4', '15-APR-2007', '02-JUN-2007')";
			statement.executeUpdate(query);
		}catch(SQLException e) { e.printStackTrace(); }
	}
qui lorsqu'il est exécuté me génère cette exception:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
java.sql.SQLException: ORA-01858: Caractère non numérique trouvé à la place d'un caractère numérique
 
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
	at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
	at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:207)
	at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:946)
	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168)
	at oracle.jdbc.driver.OracleStatement.executeUpdateInternal(OracleStatement.java:1614)
	at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1579)
	at db.Houses.test(Houses.java:223)
	at graphical.admins.AddRealEstate$10.actionPerformed(AddRealEstate.java:660)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Mais cette requête marche très bien lorsque je l'insère directement dans Oracle Express Edition 10. Que je mette les ' ' sur les nombres cela ne change rien.

Voilà comment est construite la table qui nous intéresse:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
create table REAL_ESTATES  (
   ID_REAL_ESTATE       NUMBER(10)                      not null,
   ID_PERSON            NUMBER(10)                      not null,
   SURFACE              NUMBER(3)                       not null,
   NB_OF_ROOMS          NUMBER(2)                       not null,
   TO_RENT              SMALLINT,
   TO_SELL              SMALLINT,
   PRICE_FOR_RENTING    NUMBER(10),
   PRICE_FOR_BUYING     NUMBER(10),
   AVAILABLE            SMALLINT                        not null,
   DATE_OF_PUBLICATION  DATE                            not null,
   DATE_OF_AVAILABILITY DATE                            not null,
   constraint PK_REAL_ESTATES primary key (ID_REAL_ESTATE)
);
Je tourne en rond depuis un bon moment mais je ne vois pas d'où vient l'erreur.

Si vous avez une idée n'hésitez pas

Merci et bonne journée