本文整理汇总了Java中ro.nextreports.engine.querybuilder.sql.dialect.Dialect类的典型用法代码示例。如果您正苦于以下问题:Java Dialect类的具体用法?Java Dialect怎么用?Java Dialect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Dialect类属于ro.nextreports.engine.querybuilder.sql.dialect包,在下文中一共展示了Dialect类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJavaTypeForColumn
import ro.nextreports.engine.querybuilder.sql.dialect.Dialect; //导入依赖的package包/类
private String getJavaTypeForColumn(DBColumn column) {
// dialect
Dialect dialect = null;
try {
dialect = Globals.getDialect();
// System.out.println("dialect =" + dialect + " columnType=" + column.getType() +
// " precision=" + column.getPrecision() + " scale=" + column.getScale());
return dialect.getJavaType(column.getType(), column.getPrecision(), column.getScale());
} catch (Exception ex) {
LOG.error(ex.getMessage(), ex);
ex.printStackTrace();
return "";
}
}
示例2: isValidProcedure
import ro.nextreports.engine.querybuilder.sql.dialect.Dialect; //导入依赖的package包/类
public boolean isValidProcedure(List<DBProcedureColumn> columns) {
try {
Dialect dialect = Globals.getDialect();
int out = 0;
for (DBProcedureColumn col : columns) {
if (ProcUtil.IN.equals(col.getReturnType()) || ProcUtil.VAL.equals(col.getReturnType())) {
} else if (ProcUtil.OUT.equals(col.getReturnType())) {
if (dialect instanceof OracleDialect) {
if (ProcUtil.REF_CURSOR.equals(col.getDataType())) {
out++;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
if ((out != 1) && (dialect instanceof OracleDialect)) {
return false;
}
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
示例3: getJavaTypeForColumn
import ro.nextreports.engine.querybuilder.sql.dialect.Dialect; //导入依赖的package包/类
public static String getJavaTypeForColumn(DBColumn column) {
// dialect
Dialect dialect = null;
try {
dialect = Globals.getDialect();
// System.out.println("dialect =" + dialect + " columnType=" + column.getType() +
// " precision=" + column.getPrecision() + " scale=" + column.getScale());
return dialect.getJavaType(column.getType(), column.getPrecision(), column.getScale());
} catch (Exception ex) {
ex.printStackTrace();
return "";
}
}
示例4: showReconnect
import ro.nextreports.engine.querybuilder.sql.dialect.Dialect; //导入依赖的package包/类
public static boolean showReconnect() {
Dialect dialect = null;
try {
dialect = Globals.getDialect();
} catch (Exception e1) {
e1.printStackTrace();
}
// current connection is broken
if ((dialect == null) || !ConnectionUtil.isValidConnection(Globals.getConnection(), dialect)) {
// try to create a new connection (if a connection pool is used, current connection can expire after some time)
try {
LOG.warn(".... Connection was lost. Try to recreate the database connection.");
Globals.createConnection(DefaultDataSourceManager.getInstance().getConnectedDataSource());
} catch (ConnectionException e) {
LOG.warn(".... Connection recreation was not possible.");
LOG.error(e.getMessage(), e);
// connection is really down
int option = JOptionPane.showOptionDialog(Globals.getMainFrame(),
I18NSupport.getString("connection.broken"),
I18NSupport.getString("error"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
new String[]{ I18NSupport.getString("save"), I18NSupport.getString("base.dialog.close")},
I18NSupport.getString("base.dialog.close"));
if (option != JOptionPane.OK_OPTION) {
return true;
} else {
// forced save (we should be able to save the report anyway to not lost the work)
LOG.warn(".... Forced save was called.");
new SaveAction(true).actionPerformed(null);
}
return true;
}
}
return false;
}
示例5: getDialect
import ro.nextreports.engine.querybuilder.sql.dialect.Dialect; //导入依赖的package包/类
public static Dialect getDialect() throws Exception {
if (dialect == null) {
dialect = DialectUtil.getDialect(getConnection());
}
return dialect;
}
示例6: setOutParametersValues
import ro.nextreports.engine.querybuilder.sql.dialect.Dialect; //导入依赖的package包/类
private void setOutParametersValues(PreparedStatement pstmt) throws SQLException, DialectException {
Dialect dialect = DialectUtil.getDialect(conn);
if (QueryUtil.isProcedureCall(query.getText())) {
if (dialect.hasProcedureWithCursor()) {
((CallableStatement) pstmt).registerOutParameter(outputParameterPosition,dialect.getCursorSqlType());
}
}
}
示例7: isValidProcedureCall
import ro.nextreports.engine.querybuilder.sql.dialect.Dialect; //导入依赖的package包/类
/**
* See if the sql contains only one '?' character
*
* @param sql
* sql to execute
* @param dialect
* dialect
* @return true if the sql contains only one '?' character, false otherwise
*/
public static boolean isValidProcedureCall(String sql, Dialect dialect) {
if (sql == null) {
return false;
}
if (dialect instanceof OracleDialect) {
return sql.split("\\?").length == 2;
} else {
return true;
}
}
示例8: setDialect
import ro.nextreports.engine.querybuilder.sql.dialect.Dialect; //导入依赖的package包/类
public void setDialect(Dialect dialect) {
this.dialect = dialect;
}
示例9: getDialect
import ro.nextreports.engine.querybuilder.sql.dialect.Dialect; //导入依赖的package包/类
public Dialect getDialect() {
return dialect;
}
示例10: QueryUtil
import ro.nextreports.engine.querybuilder.sql.dialect.Dialect; //导入依赖的package包/类
public QueryUtil(Connection con, Dialect dialect) {
this.con = con;
this.dialect = dialect;
}
示例11: executeQueryForColumnNames
import ro.nextreports.engine.querybuilder.sql.dialect.Dialect; //导入依赖的package包/类
public List<NameType> executeQueryForColumnNames(String sql) throws Exception {
// long t = System.currentTimeMillis();
StringWriter sw = new StringWriter(100);
// sw.append("SELECT * FROM (");
sw.append(sql);
// sw.append(") A WHERE 1 = -1");
String sqlForHeader = sw.toString();
LOG.info("call for header columns = " + sqlForHeader);
ResultSet rs = null;
Statement stmt = null;
try {
if (isProcedureCall(sqlForHeader)) {
Dialect dialect = DialectUtil.getDialect(con);
CallableStatement cs = con.prepareCall("{" + sqlForHeader + "}");
stmt = cs;
if (dialect.hasProcedureWithCursor()) {
cs.registerOutParameter(1, dialect.getCursorSqlType());
}
rs = cs.executeQuery();
if (dialect.hasProcedureWithCursor()) {
rs = (ResultSet) (cs.getObject(1));
}
} else {
stmt = con.createStatement();
stmt.setMaxRows(1);
rs = stmt.executeQuery(sqlForHeader);
}
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
List<NameType> columnNames = new ArrayList<NameType>();
for (int i = 0; i < columnCount; i++) {
columnNames.add(new NameType(rsmd.getColumnLabel(i + 1), dialect.getJavaType(rsmd.getColumnTypeName(i + 1),
rsmd.getPrecision(i + 1), rsmd.getScale(i + 1))));
// rsmd.getColumnClassName(i + 1)));
}
// t = System.currentTimeMillis() - t;
// System.out.println("execute query for column names in " + t +
// "ms");
return columnNames;
} finally {
ConnectionUtil.closeResultSet(rs);
ConnectionUtil.closeStatement(stmt);
}
}
示例12: executeQueryForDynamicColumn
import ro.nextreports.engine.querybuilder.sql.dialect.Dialect; //导入依赖的package包/类
public List<NameType> executeQueryForDynamicColumn(String sql) throws Exception {
StringWriter sw = new StringWriter(100);
sw.append(sql);
String sqlForHeader = sw.toString();
LOG.info("call for chart dynamic columns = " + sqlForHeader);
ResultSet rs = null;
Statement stmt = null;
try {
if (isProcedureCall(sqlForHeader)) {
Dialect dialect = DialectUtil.getDialect(con);
CallableStatement cs = con.prepareCall("{" + sqlForHeader + "}");
stmt = cs;
if (dialect.hasProcedureWithCursor()) {
cs.registerOutParameter(1, dialect.getCursorSqlType());
}
rs = cs.executeQuery();
if (dialect.hasProcedureWithCursor()) {
rs = (ResultSet) (cs.getObject(1));
}
} else {
stmt = con.createStatement();
rs = stmt.executeQuery(sqlForHeader);
}
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
if (columnCount != 2) {
throw new QueryException("Column query must have two data columns : column name and column legend.");
}
List<NameType> columnNames = new ArrayList<NameType>();
while (rs.next()) {
columnNames.add(new NameType(rs.getString(1), rs.getString(2)));
}
return columnNames;
} finally {
ConnectionUtil.closeResultSet(rs);
ConnectionUtil.closeStatement(stmt);
}
}
示例13: getDialect
import ro.nextreports.engine.querybuilder.sql.dialect.Dialect; //导入依赖的package包/类
public static Dialect getDialect(Connection connection) throws SQLException, DialectException {
DatabaseMetaData dbmd = connection.getMetaData();
String dbName = dbmd.getDatabaseProductName();
String dbVersion = dbmd.getDatabaseProductVersion();
return DialectFactory.determineDialect(dbName, dbVersion);
}
示例14: getValues
import ro.nextreports.engine.querybuilder.sql.dialect.Dialect; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static List<IdName> getValues(String select, Connection con) throws Exception {
List values = new ArrayList();
Dialect dialect;
DatabaseMetaData dbmd = con.getMetaData();
String dbName = dbmd.getDatabaseProductName();
String dbVersion = dbmd.getDatabaseProductVersion();
dialect = DialectFactory.determineDialect(dbName, dbVersion);
ResultSet rs = null;
Statement stmt = null;
try {
stmt = con.createStatement();
rs = stmt.executeQuery(select);
ResultSetMetaData rsmd = rs.getMetaData();
String type = rsmd.getColumnTypeName(1);
int precision = rsmd.getPrecision(1);
int scale = rsmd.getScale(1);
int typeCode = dialect.getJdbcType(type, precision, scale);
while (rs.next()) {
Serializable s;
switch (typeCode) {
case Types.INTEGER:
s = rs.getInt(1);
break;
case Types.DOUBLE:
s = rs.getDouble(1);
break;
case Types.DATE:
s = rs.getDate(1);
break;
case Types.VARCHAR:
s = rs.getString(1);
break;
default:
s = rs.getString(1);
break;
}
IdName in = new IdName();
in.setId(s);
in.setName(rs.getString(2));
values.add(in);
}
} finally {
ConnectionUtil.closeResultSet(rs);
ConnectionUtil.closeStatement(stmt);
}
return values;
}