com.microsoft.sqlserver.jdbc.SQLServerException Java Examples

The following examples show how to use com.microsoft.sqlserver.jdbc.SQLServerException. 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: MultiShardStatement.java    From elastic-db-tools-for-java with MIT License 6 votes vote down vote up
@Override
public void run() {
    SQLServerPreparedStatement stmt = (SQLServerPreparedStatement) statement;
    try {
        switch (type) {
            // TODO: Add all types
            case Types.STRUCT:
                if (objects.length == 2) {
                    stmt.setStructured(index, (String) objects[0], (SQLServerDataTable) objects[1]);
                }
                break;
            default:
                throw new RuntimeException("Not Supported yet!",
                        new UnsupportedOperationException(String.format("This SQL Type (%1$s) cannot be added to the statement using this"
                                + " method. Please add the same as an inline parameter at %2$s index.", type, index)));
        }
    }
    catch (SQLServerException ex) {
        throw new RuntimeException(ex);
    }
}
 
Example #2
Source File: SQLServerVertexGlobalUniqueIndexBulkRecord.java    From sqlg with MIT License 5 votes vote down vote up
SQLServerVertexGlobalUniqueIndexBulkRecord(SQLServerBulkCopy bulkCopy,
                                           SqlgGraph sqlgGraph,
                                           Pair<SortedSet<String>,
                                             Map<SqlgVertex, Map<String, Object>>> vertices,
                                           PropertyColumn propertyColumn
) throws SQLServerException {
    this.rowIter = vertices.getRight().entrySet().iterator();
    this.propertyColumn = propertyColumn;

    bulkCopy.addColumnMapping(1, GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_VALUE);
    this.columnMetadata.put(1, new ColumnMetadata(
            GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_VALUE,
            sqlgGraph.getSqlDialect().propertyTypeToJavaSqlType(PropertyType.STRING)[0],
            0,
            0,
            null,
            PropertyType.STRING
    ));
    bulkCopy.addColumnMapping(2, GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_RECORD_ID);
    this.columnMetadata.put(2, new ColumnMetadata(
            GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_RECORD_ID,
            sqlgGraph.getSqlDialect().propertyTypeToJavaSqlType(PropertyType.STRING)[0],
            0,
            0,
            null,
            PropertyType.STRING
    ));
    bulkCopy.addColumnMapping(3, GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_PROPERTY_NAME);
    this.columnMetadata.put(3, new ColumnMetadata(
            GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_PROPERTY_NAME,
            sqlgGraph.getSqlDialect().propertyTypeToJavaSqlType(PropertyType.STRING)[0],
            0,
            0,
            null,
            PropertyType.STRING
    ));
}
 
Example #3
Source File: SQLServerEdgeGlobalUniqueIndexBulkRecord.java    From sqlg with MIT License 5 votes vote down vote up
SQLServerEdgeGlobalUniqueIndexBulkRecord(SQLServerBulkCopy bulkCopy,
                                         SqlgGraph sqlgGraph,
                                         Map<SqlgEdge, Triple<SqlgVertex, SqlgVertex, Map<String, Object>>> edgeMap,
                                         PropertyColumn propertyColumn
) throws SQLServerException {

    this.rowIter = edgeMap.entrySet().iterator();
    this.propertyColumn = propertyColumn;

    bulkCopy.addColumnMapping(1, GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_VALUE);
    this.columnMetadata.put(1, new ColumnMetadata(
            GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_VALUE,
            sqlgGraph.getSqlDialect().propertyTypeToJavaSqlType(PropertyType.STRING)[0],
            0,
            0,
            null,
            PropertyType.STRING
    ));
    bulkCopy.addColumnMapping(2, GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_RECORD_ID);
    this.columnMetadata.put(2, new ColumnMetadata(
            GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_RECORD_ID,
            sqlgGraph.getSqlDialect().propertyTypeToJavaSqlType(PropertyType.STRING)[0],
            0,
            0,
            null,
            PropertyType.STRING
    ));
    bulkCopy.addColumnMapping(3, GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_PROPERTY_NAME);
    this.columnMetadata.put(3, new ColumnMetadata(
            GlobalUniqueIndex.GLOBAL_UNIQUE_INDEX_PROPERTY_NAME,
            sqlgGraph.getSqlDialect().propertyTypeToJavaSqlType(PropertyType.STRING)[0],
            0,
            0,
            null,
            PropertyType.STRING
    ));
}
 
Example #4
Source File: SQLServerVertexCacheBulkRecord.java    From sqlg with MIT License 5 votes vote down vote up
SQLServerVertexCacheBulkRecord(SQLServerBulkCopy bulkCopy, SqlgGraph sqlgGraph, SchemaTable schemaTable, Pair<SortedSet<String>, Map<SqlgVertex, Map<String, Object>>> vertices) throws SQLServerException {
    this.rowIter = vertices.getRight().entrySet().iterator();
    if (!schemaTable.isTemporary()) {
        this.propertyColumns = sqlgGraph.getTopology()
                .getSchema(schemaTable.getSchema()).orElseThrow(() -> new IllegalStateException(String.format("Schema %s not found", schemaTable.getSchema())))
                .getVertexLabel(schemaTable.getTable()).orElseThrow(() -> new IllegalStateException(String.format("VertexLabel %s not found", schemaTable.getTable())))
                .getProperties();
    } else {
        this.properties = sqlgGraph.getTopology().getPublicSchema().getTemporaryTable(VERTEX_PREFIX + schemaTable.getTable());
    }
    int i = 1;
    this.columns = vertices.getLeft();
    this.dummy = this.columns.isEmpty();
    if (this.dummy) {
        bulkCopy.addColumnMapping(i, "dummy");
        this.columnMetadata.put(i, new ColumnMetadata(
                "dummy",
                sqlgGraph.getSqlDialect().propertyTypeToJavaSqlType(PropertyType.INTEGER)[0],
                0,
                0,
                null,
                PropertyType.INTEGER
        ));
    } else {
        addMetaData(bulkCopy, sqlgGraph);
    }
}