Announcement Announcement Module
Collapse
No announcement yet.
simpleJdbcInsert withCatalogName not working Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • simpleJdbcInsert withCatalogName not working

    I am using spring 3.0.5. and trying to insert a record in a table that is in different catalog from datasource catalog

    here the datasource bean in applicationContext.xml file

    <bean id="sqlDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="maxActive" value="10"/>
    <property name="maxIdle" value="5" />
    <property name="minIdle" value="5"/>
    <property name="maxWait" value="10000" />
    <property name="testOnBorrow" value="true" />
    <property name="validationQuery" value="select 1" />
    <property name="testWhileIdle" value="true" />
    <property name="timeBetweenEvictionRunsMillis" value="600000"/>
    <property name="minEvictableIdleTimeMillis" value="1200000"/>
    <property name="numTestsPerEvictionRun" value="-1"/>
    <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
    <property name="url" value="jdbc:jtds:sqlserver://192.168.1.126:1433/SUMINISTROS;prepareSQL=0;SendStringParametersAsUni code=False;" />
    <property name="username" value="pooling" />
    <property name="password" value="pooling" />
    </bean>

    The catalog name is SUMINISTROS

    This is my dao implementation for simpleJdbcInsert

    @Override
    public int insertRecord(ControlDto controlDto) throws DataAccessException {

    SimpleJdbcInsert simpleJdbcInsert = new SimpleJdbcInsert(getDataSource())
    .withCatalogName("ACTIVOS")
    .withSchemaName("dbo")
    .withTableName("CONTROL");
    SqlParameterSource sqlParameterSource = new BeanPropertySqlParameterSource(controlDto);
    return simpleJdbcInsert.execute(sqlParameterSource);
    }

    the catalog i am using is ACTIVOS, but the instruction is giving me the error

    PreparedStatementCallback; bad SQL grammar [INSERT INTO dbo.CONTROL (compania, sucursal, moneda, referencia, ultimo_proceso, depreciacion, ext_facturas, ext_activos, ruta_imagenes, cuenta_temporal, cuenta_ajuste,dia_corte, sumarizar_gastos, servidor, ultimo_cierre, usuario_cierre)
    VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is java.sql.SQLException: Invalid object name 'dbo.CONTROL'.

    Catalog property is not inserting into the sentence "INSERT INTO dbo.CONTROL" is missing and the object dbo.CONTROL is not found.
    There is something i'm doing wrong.
Working...
X