Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'develop' of github.com:wolfgangmm/exist into develop

  • Loading branch information...
commit ad90b977f4384d556e39c434e8b72b52d4c722d1 2 parents 679eb3c + 6f83e2a
@wolfgangmm wolfgangmm authored
View
BIN  extensions/betterform/main/lib/betterform.jar
Binary file not shown
View
2  extensions/betterform/main/webapp/WEB-INF/betterform-version.info
@@ -1 +1 @@
-betterFORM 5.0rc7 - buildNumber:12097 - Timestamp:2014-06-30 17:30:46
+betterFORM 5.0rc8 - buildNumber:12134 - Timestamp:2014-07-08 17:32:23
View
46 extensions/modules/src/org/exist/xquery/modules/sql/ExecuteFunction.java
@@ -65,7 +65,6 @@
import org.exist.memtree.SAXAdapter;
import org.exist.xquery.value.DateTimeValue;
import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
@@ -172,6 +171,7 @@ public ExecuteFunction( XQueryContext context, FunctionSignature signature )
//execute the statement
executeResult = stmt.execute( sql );
+
} else if( args.length == 4 ) {
preparedStmt = true;
@@ -192,6 +192,8 @@ public ExecuteFunction( XQueryContext context, FunctionSignature signature )
} else {
//TODO throw exception
}
+
+ // DW: stmt can be null ?
// execute the query statement
@@ -425,29 +427,33 @@ public ExecuteFunction( XQueryContext context, FunctionSignature signature )
private void setParametersOnPreparedStatement( Statement stmt, Element parametersElement ) throws SQLException, XPathException
{
- if( parametersElement.getNamespaceURI().equals( SQLModule.NAMESPACE_URI ) && parametersElement.getLocalName().equals( PARAMETERS_ELEMENT_NAME ) ) {
- NodeList paramElements = parametersElement.getElementsByTagNameNS( SQLModule.NAMESPACE_URI, PARAM_ELEMENT_NAME );
+ if (parametersElement.getNamespaceURI().equals(SQLModule.NAMESPACE_URI) && parametersElement.getLocalName().equals(PARAMETERS_ELEMENT_NAME)) {
+ NodeList paramElements = parametersElement.getElementsByTagNameNS(SQLModule.NAMESPACE_URI, PARAM_ELEMENT_NAME);
- for( int i = 0; i < paramElements.getLength(); i++ ) {
- Element param = ( (Element)paramElements.item( i ) );
+ for (int i = 0; i < paramElements.getLength(); i++) {
+ Element param = ((Element) paramElements.item(i));
Node child = param.getFirstChild();
- if(child instanceof ReferenceNode) {
- child = ((ReferenceNode)child).getReference().getNode();
- }
-
- final String value = child.getNodeValue();
- final String type = param.getAttributeNS( SQLModule.NAMESPACE_URI, TYPE_ATTRIBUTE_NAME );
- final int sqlType = SQLUtils.sqlTypeFromString(type);
-
- if(sqlType == Types.TIMESTAMP) {
- final DateTimeValue dv = new DateTimeValue(value);
- final Timestamp timestampValue = new Timestamp(dv.getDate().getTime());
- ((PreparedStatement)stmt).setTimestamp(i+1, timestampValue);
- } else {
- ((PreparedStatement)stmt).setObject(i+1, value, sqlType);
+
+ // Prevent NPE
+ if (child != null) {
+ if (child instanceof ReferenceNode) {
+ child = ((ReferenceNode) child).getReference().getNode();
+ }
+
+ final String value = child.getNodeValue();
+ final String type = param.getAttributeNS(SQLModule.NAMESPACE_URI, TYPE_ATTRIBUTE_NAME);
+ final int sqlType = SQLUtils.sqlTypeFromString(type);
+
+ if (sqlType == Types.TIMESTAMP) {
+ final DateTimeValue dv = new DateTimeValue(value);
+ final Timestamp timestampValue = new Timestamp(dv.getDate().getTime());
+ ((PreparedStatement) stmt).setTimestamp(i + 1, timestampValue);
+
+ } else {
+ ((PreparedStatement) stmt).setObject(i + 1, value, sqlType);
+ }
}
-
}
}
}
View
2  extensions/modules/src/org/exist/xquery/modules/sql/SQLModule.java
@@ -65,7 +65,7 @@
new FunctionDef(ExecuteFunction.signatures[1], ExecuteFunction.class),
new FunctionDef(PrepareFunction.signatures[0], PrepareFunction.class)
};
- private static long currentUID = System.currentTimeMillis();
+ private static final long currentUID = System.currentTimeMillis();
public final static String CONNECTIONS_CONTEXTVAR = "_eXist_sql_connections";
public final static String PREPARED_STATEMENTS_CONTEXTVAR = "_eXist_sql_prepared_statements";
View
123 extensions/modules/src/org/exist/xquery/modules/sql/SQLUtils.java
@@ -19,46 +19,47 @@ public static int sqlTypeFromString( String sqlType )
{
sqlType = sqlType.toUpperCase();
- if( sqlType.equals( "ARRAY" ) ) {
- return( Types.ARRAY );
- } else if( sqlType.equals( "BIGINT" ) ) {
- return( Types.BIGINT );
- } else if( sqlType.equals( "BINARY" ) ) {
- return( Types.BINARY );
- } else if( sqlType.equals( "BIT" ) ) {
- return( Types.BIT );
- } else if( sqlType.equals( "BLOB" ) ) {
- return( Types.BLOB );
- } else if( sqlType.equals( "BOOLEAN" ) ) {
- return( Types.BOOLEAN );
- } else if( sqlType.equals( "CHAR" ) ) {
- return( Types.CHAR );
- } else if( sqlType.equals( "CLOB" ) ) {
- return( Types.CLOB );
- } else if( sqlType.equals( "DECIMAL" ) ) {
- return( Types.DECIMAL );
- } else if( sqlType.equals( "DOUBLE" ) ) {
- return( Types.DOUBLE );
- } else if( sqlType.equals( "FLOAT" ) ) {
- return( Types.FLOAT );
- } else if( sqlType.equals( "LONGVARCHAR" ) ) {
- return( Types.LONGVARCHAR );
- } else if( sqlType.equals( "NUMERIC" ) ) {
- return( Types.NUMERIC );
- } else if( sqlType.equals( "SMALLINT" ) ) {
- return( Types.SMALLINT );
- } else if( sqlType.equals( "TINYINT" ) ) {
- return( Types.TINYINT );
- } else if( sqlType.equals( "INTEGER" ) ) {
- return( Types.INTEGER );
- } else if( sqlType.equals( "VARCHAR" ) ) {
- return( Types.VARCHAR );
- } else if(sqlType.equals("SQLXML")) {
- return Types.SQLXML;
- } else if(sqlType.equals("TIMESTAMP")) {
- return Types.TIMESTAMP;
- } else {
- return( Types.VARCHAR ); //default
+ switch (sqlType) {
+ case "ARRAY":
+ return (Types.ARRAY);
+ case "BIGINT":
+ return (Types.BIGINT);
+ case "BINARY":
+ return (Types.BINARY);
+ case "BIT":
+ return (Types.BIT);
+ case "BLOB":
+ return (Types.BLOB);
+ case "BOOLEAN":
+ return (Types.BOOLEAN);
+ case "CHAR":
+ return (Types.CHAR);
+ case "CLOB":
+ return (Types.CLOB);
+ case "DECIMAL":
+ return (Types.DECIMAL);
+ case "DOUBLE":
+ return (Types.DOUBLE);
+ case "FLOAT":
+ return (Types.FLOAT);
+ case "LONGVARCHAR":
+ return (Types.LONGVARCHAR);
+ case "NUMERIC":
+ return (Types.NUMERIC);
+ case "SMALLINT":
+ return (Types.SMALLINT);
+ case "TINYINT":
+ return (Types.TINYINT);
+ case "INTEGER":
+ return (Types.INTEGER);
+ case "VARCHAR":
+ return (Types.VARCHAR);
+ case "SQLXML":
+ return Types.SQLXML;
+ case "TIMESTAMP":
+ return Types.TIMESTAMP;
+ default:
+ return (Types.VARCHAR); //default
}
}
@@ -71,86 +72,86 @@ public static int sqlTypeFromString( String sqlType )
*/
public static int sqlTypeToXMLType( int sqlType )
{
- switch( sqlType ) {
+ switch (sqlType) {
case Types.ARRAY: {
- return( Type.NODE );
+ return (Type.NODE);
}
case Types.BIGINT: {
- return( Type.INT );
+ return (Type.INT);
}
case Types.BINARY: {
- return( Type.BASE64_BINARY );
+ return (Type.BASE64_BINARY);
}
case Types.BIT: {
- return( Type.INT );
+ return (Type.INT);
}
case Types.BLOB: {
- return( Type.BASE64_BINARY );
+ return (Type.BASE64_BINARY);
}
case Types.BOOLEAN: {
- return( Type.BOOLEAN );
+ return (Type.BOOLEAN);
}
case Types.CHAR: {
- return( Type.STRING );
+ return (Type.STRING);
}
case Types.CLOB: {
- return( Type.STRING );
+ return (Type.STRING);
}
case Types.DECIMAL: {
- return( Type.DECIMAL );
+ return (Type.DECIMAL);
}
case Types.DOUBLE: {
- return( Type.DOUBLE );
+ return (Type.DOUBLE);
}
case Types.FLOAT: {
- return( Type.FLOAT );
+ return (Type.FLOAT);
}
case Types.LONGVARCHAR: {
- return( Type.STRING );
+ return (Type.STRING);
}
case Types.NUMERIC: {
- return( Type.NUMBER );
+ return (Type.NUMBER);
}
case Types.SMALLINT: {
- return( Type.INT );
+ return (Type.INT);
}
case Types.TINYINT: {
- return( Type.INT );
+ return (Type.INT);
}
case Types.INTEGER: {
- return( Type.INTEGER );
+ return (Type.INTEGER);
}
case Types.VARCHAR: {
- return( Type.STRING );
+ return (Type.STRING);
}
case Types.SQLXML: {
- return(Type.NODE);
+ return (Type.NODE);
}
-
+
case Types.TIMESTAMP: {
return Type.DATE_TIME;
}
default: {
- return( Type.ANY_TYPE );
+ return (Type.ANY_TYPE);
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.