create remote db via JDBC?

I

iksrazal

Hi all,
From the command line on the local machine I do this:

/home/iksrazal> mysql -u user -ppassword mydb < mydb.sql

That creates a new db instance and populates the tables with default
data. I need to:

1) Create a new db with the file shown from inside a servlet container.

2) The file could be anywhere on the same machine as the servlet
container.
3) The db is on another machine.
4) The db is mysql 4.1 .

What I think does not work is mysqlimport - as it seemingly only works
with tables, not a full db. And RunTimeExec - as how would I do that
when the db is remote?

Any ideas?
iksrazal
 
I

iksrazal

I just remembered RunTimeExec could work as the mysql command accepts a
host name. But is RunTimeExec the only way ? I'd prefer another way,
such as with directly with JDBC, if possible.
 
I

iksrazal

the mydb.sql file contains ordinary sql commands, just put them in your
program instead

Excellent idea and I gave it a shot. But the comments get in the way,
and even assumming I could parse those out, I still get commands like
this:

SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS;

And

USE `c4`;

That sort of thing. The file I have is direct from mysqldump and I want
to execute it as is.

iksrazal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top