File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and the fly likes Problem with Java - MySQL connection inUnix environment. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem with Java - MySQL connection inUnix environment." Watch "Problem with Java - MySQL connection inUnix environment." New topic

Problem with Java - MySQL connection inUnix environment.

Andy Saxena

Joined: Aug 09, 2012
Posts: 4
Hi Guys,

I am working on an application which requires me to download a database (basically database files - .myd, .frm, .myi and db.opt) from a server and load them to the local MySQL database.
Now I am able to get the files successfully and replace the existing files with the new ones in local database folder. But the problem is that MySQL continues to read the files from the previous database.
I tried stopping and restarting the server manually, with root privileges, and then the MySQL was reading proper files. But the problem is that I can not do this from the code because the code may be executed from an account that doesn't have root privileges.

So can someone please help me with a way with which I can refresh the database or make the database read proper new files.

Also, I was just wondering if I have replaced the older files from the database, how come the database can still read those files ?

Many thanks.

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38087
Welcome to the Ranch
I shall move this discussion to one of our database fora.

You cannot simply replace files in a database. Your files contain SQL instructions (I hope) which allow you to update the database. You would have to execute them, possibly from the MySQL command line.
Wendy Gibbons

Joined: Oct 21, 2008
Posts: 1107

well actually you can, in my old company we just used to share the mysql files to test problems, or if somebody updated the schema, a cry would go round the office (we didn't have email) "updated the schema new file on shared drive"

But this only works on the older MySql database types, not with the new setting that was introduced in MySQL 5.
Wendy Gibbons

Joined: Oct 21, 2008
Posts: 1107

But as to the problem it is insumountable, you really can't go round giving every user root privilages, and you can't go round letting every user reboot your database.

Why do you want everyone being able to change your DB on the fly?
Andy Saxena

Joined: Aug 09, 2012
Posts: 4
Actually the application is a client which will download the db files from a remote server and copy those files in the local mysql database. The previous files in the db are deleted and new ones are placed in that location.
Now, every user can not be a root user but they are allowed to run this application. So I was wondering if there is a way where in the mysql database can reload the database after the file copying operation is over.

As far as my understanding goes , non - root users can not stop and start mysql service.

So the only option left with me is to drop the database and reload it again. But that is also not happening, it throws MySQL Error 13 - Error on delete <DBname>/db.opt

Am really stuck guys , help me out !

It is sorta covered in the JavaRanch Style Guide.
subject: Problem with Java - MySQL connection inUnix environment.
Similar Threads
Clean full registry after MySQL uninstall...
expand java console
New to Linux!!!
Problem when creating stored procedure in MySql5.0
Slackware & Mysql error install