>
> Thansks for your great reply. I did this code so far. Could you have a 
>> look into it , and tell me if I'm doing something wrong?. I tell you so 
>> because for importing 4000 movies, my program needs 6 minutes, and I think 
>> is a lot...
>>
>
CODE
---------------------------

> Class.forName("org.h2.Driver");
>
> Connection conn = DriverManager.getConnection("jdbc:h2:"
>
> + FilenameUtils.concat(GlobalSettings.TEMP_DIR, "Portable")
>
> + ";LOG=0;CACHE_SIZE=65536;LOCK_MODE=0;UNDO_LOG=0"
>
> + ";IFEXISTS=TRUE", "sa", "");
>
> DatabaseFactory.connection.setAutoCommit(false);
>
> String sqlCount = "SELECT * FROM Movies";
>
> Statement statement = conn.createStatement();
>
> ResultSet result = statement.executeQuery(sqlCount);
>
> result.next();
>
> while (result.next()) {
>
>  OldMovie085 om = null;
>>
> Movie movie = null;
>
> om = new OldMovie085(conn, result);
>
> movie = new Movie();
>>
> movie.setKey(om.getKey());
>
> movie.setTitle(om.getTitle());
>
> movie.setOriginalTitle(om.getOriginalTitle());
>
> movie.setCategory(om.getCategory());
>
> movie.setDirector(om.getDirector());
>
>   movie.setProducer(om.getProducer());
movie.setWriter(om.getWriter());
movie.setMusic(om.getMusic());
movie.setPhotographer("");

movie.setBoxSet("");
movie.setReasonMarked("");
movie.setLanguage("");
movie.setSubtitle("");
movie.setUrlInfo1("");
movie.setUrlInfo2("");
movie.setUrlInfo3("");
movie.setMoviePath("");
movie.setTrailerPath("");
movie.setType(om.getType());
movie.setFormat(om.getFormat());
movie.setSeen(om.isSeen());
MOVIE.INSERT()

 }

conn.close();
result.close();
statement.close();


So, what I'm doing is open 2 connections (old database and new database). I 
keep open 2 Connection objects.
I load ALL the objects (4000 or 5000 movies), and into old movie object 
with getters, I do the parsing to correct format (String , Date, etc...).
I fill the new object with the getter results and when I'm done with all 
the fields( I have a lot more, but I've only written a couple) I call 
Movie.Insert() to insert movie object into new database.
I do the same with all the 4000 or 5000 movies.

But it's slow, so I would be glad to have a different opinion to optimize 
this code. Thanks!!

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/h2-database/-/pUfp47KUJ10J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to