
com.jk.data.backup.ImportManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jk-framework-data Show documentation
Show all versions of jk-framework-data Show documentation
This contains a set of API's that ease the database programming with Java, in both: JDBC and JPA Persisitnce).
/*
* Copyright 2002-2021 Dr. Jalal Kiswani.
* Email: [email protected]
* Check out https://smart-api.com for more details
*
* All the opensource projects of Dr. Jalal Kiswani are free for personal and academic use only,
* for commercial usage and support, please contact the author.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jk.data.backup;
import com.jk.core.exceptions.JKValidationException;
import com.jk.core.util.JKIOUtil;
import com.jk.data.dataaccess.JKDataAccessFactory;
// TODO: Auto-generated Javadoc
/**
* The Class ImportManager.
*/
public class ImportManager {
/** The sql file path. */
private final String sqlFilePath;
/**
* Instantiates a new import manager.
*
* @param sqlFilePath the sql file path
* @throws JKValidationException the JK validation exception
*/
public ImportManager(final String sqlFilePath) throws JKValidationException {
if (JKIOUtil.isEmpty(sqlFilePath)) {
throw new JKValidationException("SQL_FILE_PATH_CAN_NOT_BE_EMPTY");
}
this.sqlFilePath = sqlFilePath;
}
/**
* Do import.
*
* @return true, if successful
* @throws Exception the exception
*/
public boolean doImport() throws Exception {
final DatabaseInfo dbInfo = new DatabaseInfo(JKDataAccessFactory.getDefaultDataSource());
dbInfo.setFileName(this.sqlFilePath);
MySqlUtil.importDb(dbInfo);
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy