Bonjour à tous,

J'ai un algorithme qui doit permettre d'enregistrer 700 000 enregistrements dans ma BDD, seulement j'obtiens ce message d'erreur à l'enregistrement 574212... :

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
 
Exception in thread "Thread-0" java.lang.OutOfMemoryError: Java heap space
        at java.lang.StringCoding$StringEncoder.encode(StringCoding.java:249)
        at java.lang.StringCoding.encode(StringCoding.java:289)
        at java.lang.String.getBytes(String.java:954)
        at com.mysql.jdbc.StringUtils.getBytes(StringUtils.java:560)
        at com.mysql.jdbc.StringUtils.getBytes(StringUtils.java:719)
        at com.mysql.jdbc.Buffer.writeStringNoNull(Buffer.java:704)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2595)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2728)
        at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1811)
        at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1899)
        at database.Database.query(Database.java:55)
        at game.world.World.createWorld(World.java:247)
        at game.world.World.loadWorld(World.java:49)
        at game.GameManager.loadWorld(GameManager.java:41)
        at network.Server.start(Server.java:34)
        at core.Application.run(Application.java:23)
        at java.lang.Thread.run(Thread.java:679)
World.java : (Algo qui déclenche l'exception)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
String req;
 
		for(int i=0;i<XSIZEWORLD;i++) {
			for(int j=0;j<YSIZEWORLD;j++) {
 
				req = "INSERT INTO REGION (id_region, libelle_region, id_climat)" +
						"VALUES (NULL,  'SE_"+numRegion+"', '"+climat+"')";
				this._db.query(req);
}
}
Database.java :
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
 
	public int query(String req) {
		Statement state = null;
		ResultSet rs = null;
		int id = 0;
 
		try {
			state = (Statement) conn.createStatement();
			state.executeUpdate(req, Statement.RETURN_GENERATED_KEYS);
 
			rs = state.getGeneratedKeys();
			if (rs.next()){
				id=rs.getInt(1);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
 
		state = null;
		rs = null;
		req = null;
 
		return id;
	}
Est-ce qu'il y a des choses qui vous choque ? J'ai beau exécuter comme ceci :
java -jar se.jar -server -port 20000 -Xms1024M -Xmx2048M -Xss1024M
Rien à faire...

Une petite aide serait la bienvenue...