my try block looks like:
the next sql 2 commands tried:
mysql -hhost -uuse -ppassword database < sqlFlie
and
musqlimport -hhost -uuser -ppassword database sqlFile
I also find it strange because no error or exception is found or thrown. so it executes it, but nothing happens (no restore is happened)...
my sql file looks like:
-- Host: 127.0.0.1 Database: mysouq3_db
-- ------------------------------------------------------
-- Server version4.1.8-nt
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;
--
-- Table structure for table `admin`
--
DROP TABLE IF EXISTS `admin`;
CREATE TABLE `admin` (
`username` varchar(100) NOT NULL default '',
`password` varchar(100) NOT NULL default '',
`role` varchar(100) NOT NULL default '',
PRIMARY KEY (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `admin`
--
/*!40000 ALTER TABLE `admin` DISABLE KEYS */;
LOCK TABLES `admin` WRITE;
INSERT INTO `admin` VALUES ('admin','admin','admin');
UNLOCK TABLES;
/*!40000 ALTER TABLE `admin` ENABLE KEYS */;
My
Java code looks like:
try
{
Runtime rt = Runtime.getRuntime();
String host = "127.0.0.1";
String user = Config.DB_USERNAME;
String pw = Config.DB_PASSWORD;
String db = Config.DB_NAME;
String restoreDatabase = this.getRestoreDatabase(baseDir+fileName);
String command = "mysqlimport -h"+host+" -u"+user+" -p"+pw+" "+db+ " "+baseDir+fileName;
log.info("restore db quesy is: "+command);
rt.exec(command);
log.info("end try");
}