Re: Execute more sql statments in one step.
- From: Daniel Dittmar <daniel.dittmar@xxxxxxxx>
- Date: Tue, 12 Apr 2005 13:24:35 +0200
PdG wrote:
[...]Daniel Dittmar wrote:
Have i to use a specific method to run multiple instructions? I've tried execute, executeBatch() but the results are the same...
The scenery is a client-server application. One server, about 100 clients.
Every client have a java application, a mysql database, and, inside the application, a "live update" function that connects to the server, look if there's some new updates, and download it.
Before today the update works only for the client binary (jar) and not for the database structure. Now i've to implement also a update mechanism for the database.
It's, for me, more easy to create an unique .sql file which contains all the sql statments needs to modify the database, instead of a lot of files with single sql statments.
For example one table is a list of prices, and every update it could be increased about 400 records: do 400 separated query is not very confortable.
There's no way to connect directly the mysql of the client (firewalls etc..) so i've to do it from java.
OK, sounds reasonable.
I guess you have to break the file into individual statements in your java program. I assume that the mysql client does this as well rather than sending the whole input as one command to the database.
Searching for lines that end in ';' is not difficult. But could there be cases where this appears inside a sql command? Are literals containing new lines written as ';\n' or as ';
'?
If you write the .sql file yourself, you could choose a different command delimiter and make sure that this delimiter does not appear in normal SQL.
You could also go the road of buzzword bingo and transfer everything as XML.
If the .sql file is written by the database itself, you could
- make your java classes smart enough to break the file apart
- search for some Open Source script that knows how to parse .sql files. Run it on the server and generate a file that is more easily handled by you java clients.
Daniel .
- Follow-Ups:
- References:
- Execute more sql statments in one step.
- From: PdG
- Re: Execute more sql statments in one step.
- From: Daniel Dittmar
- Re: Execute more sql statments in one step.
- From: PdG
- Execute more sql statments in one step.
- Prev by Date: Re: Execute more sql statments in one step.
- Next by Date: Re: Execute more sql statments in one step.
- Previous by thread: Re: Execute more sql statments in one step.
- Next by thread: Re: Execute more sql statments in one step.
- Index(es):
Relevant Pages
|