Java Code Examples for org.jeecg.common.constant.DataBaseConstant#DB_TYPE_MYSQL

The following examples show how to use org.jeecg.common.constant.DataBaseConstant#DB_TYPE_MYSQL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SysBaseApiImpl.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * 获取数据库类型
 * @param dataSource
 * @return
 * @throws SQLException
 */
private String getDatabaseTypeByDataSource(DataSource dataSource) throws SQLException{
	if("".equals(DB_TYPE)) {
		Connection connection = dataSource.getConnection();
		try {
			DatabaseMetaData md = connection.getMetaData();
			String dbType = md.getDatabaseProductName().toLowerCase();
			if(dbType.indexOf("mysql")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_MYSQL;
			}else if(dbType.indexOf("oracle")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_ORACLE;
			}else if(dbType.indexOf("sqlserver")>=0||dbType.indexOf("sql server")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_SQLSERVER;
			}else if(dbType.indexOf("postgresql")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_POSTGRESQL;
			}else {
				throw new JeecgBootException("数据库类型:["+dbType+"]不识别!");
			}
		} catch (Exception e) {
			log.error(e.getMessage(), e);
		}finally {
			connection.close();
		}
	}
	return DB_TYPE;
	
}
 
Example 2
Source File: CommonUtils.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * 获取数据库类型
 * @param dataSource
 * @return
 * @throws SQLException
 */
private static String getDatabaseTypeByDataSource(DataSource dataSource) throws SQLException{
    if("".equals(DB_TYPE)) {
        Connection connection = dataSource.getConnection();
        try {
            DatabaseMetaData md = connection.getMetaData();
            String dbType = md.getDatabaseProductName().toLowerCase();
            if(dbType.indexOf("mysql")>=0) {
                DB_TYPE = DataBaseConstant.DB_TYPE_MYSQL;
            }else if(dbType.indexOf("oracle")>=0) {
                DB_TYPE = DataBaseConstant.DB_TYPE_ORACLE;
            }else if(dbType.indexOf("sqlserver")>=0||dbType.indexOf("sql server")>=0) {
                DB_TYPE = DataBaseConstant.DB_TYPE_SQLSERVER;
            }else if(dbType.indexOf("postgresql")>=0) {
                DB_TYPE = DataBaseConstant.DB_TYPE_POSTGRESQL;
            }else {
                throw new JeecgBootException("数据库类型:["+dbType+"]不识别!");
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }finally {
            connection.close();
        }
    }
    return DB_TYPE;

}
 
Example 3
Source File: SysBaseApiImpl.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * 获取数据库类型
 * @param dataSource
 * @return
 * @throws SQLException
 */
private String getDatabaseTypeByDataSource(DataSource dataSource) throws SQLException{
	if("".equals(DB_TYPE)) {
		Connection connection = dataSource.getConnection();
		try {
			DatabaseMetaData md = connection.getMetaData();
			String dbType = md.getDatabaseProductName().toLowerCase();
			if(dbType.indexOf("mysql")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_MYSQL;
			}else if(dbType.indexOf("oracle")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_ORACLE;
			}else if(dbType.indexOf("sqlserver")>=0||dbType.indexOf("sql server")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_SQLSERVER;
			}else if(dbType.indexOf("postgresql")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_POSTGRESQL;
			}else {
				throw new JeecgBootException("数据库类型:["+dbType+"]不识别!");
			}
		} catch (Exception e) {
			log.error(e.getMessage(), e);
		}finally {
			connection.close();
		}
	}
	return DB_TYPE;
	
}
 
Example 4
Source File: SysBaseApiImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 获取数据库类型
 * @param dataSource
 * @return
 * @throws SQLException
 */
private String getDatabaseTypeByDataSource(DataSource dataSource) throws SQLException{
	if("".equals(DB_TYPE)) {
		Connection connection = dataSource.getConnection();
		try {
			DatabaseMetaData md = connection.getMetaData();
			String dbType = md.getDatabaseProductName().toLowerCase();
			if(dbType.indexOf("mysql")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_MYSQL;
			}else if(dbType.indexOf("oracle")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_ORACLE;
			}else if(dbType.indexOf("sqlserver")>=0||dbType.indexOf("sql server")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_SQLSERVER;
			}else if(dbType.indexOf("postgresql")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_POSTGRESQL;
			}else {
				throw new JeecgBootException("数据库类型:["+dbType+"]不识别!");
			}
		} catch (Exception e) {
			log.error(e.getMessage(), e);
		}finally {
			connection.close();
		}
	}
	return DB_TYPE;
	
}
 
Example 5
Source File: SysBaseApiImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 获取数据库类型
 * @param dataSource
 * @return
 * @throws SQLException
 */
private String getDatabaseTypeByDataSource(DataSource dataSource) throws SQLException{
	if("".equals(DB_TYPE)) {
		Connection connection = dataSource.getConnection();
		try {
			DatabaseMetaData md = connection.getMetaData();
			String dbType = md.getDatabaseProductName().toLowerCase();
			if(dbType.indexOf("mysql")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_MYSQL;
			}else if(dbType.indexOf("oracle")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_ORACLE;
			}else if(dbType.indexOf("sqlserver")>=0||dbType.indexOf("sql server")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_SQLSERVER;
			}else if(dbType.indexOf("postgresql")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_POSTGRESQL;
			}else {
				throw new JeecgBootException("数据库类型:["+dbType+"]不识别!");
			}
		} catch (Exception e) {
			log.error(e.getMessage(), e);
		}finally {
			connection.close();
		}
	}
	return DB_TYPE;
	
}