+ Start a Discussion
IPFramptonIPFrampton 

Error connecting to MSSQL Database with Data Loader

Afternoon,

I am trying to do an insert into a MS SQL Server 2012 Database with the Data Loader from command line, however, I am greeted with the following error every time I try and do the insert (I have replaced the path to config here):

2015-01-26 14:14:34,954 FATAL [insertAccountIDs] controller.Controller createDao (Controller.java:186) - Error creating data access object
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 55 in XML document from file [<PATH TO CONFIG>\database-conf.xml] is invalid; nested exception is org.xml.sax.SAXParseException: The content of element type "beans" must match "(description?,(import|alias|bean)*)".

This is my database-conf.xml file:
 
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
  <bean id="sqlServerDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
    <property name="url" value="jdbc:sqlserver://localhost;databaseName=testDB;"/>
</bean>
-<bean id="insertAccountIDs" class="com.salesforce.dataloader.dao.database.DatabaseConfig" singleton="true">
	<property name="sqlConfig" ref="insertAccountIDsSQL"/>
	<property name="dataSource" ref="sqlServerDataSource"/>
</bean>
<bean id="insertAccountIDsSQL" class="com.salesforce.dataloader.dao.database.SqlConfig" singleton="true">
    <property name="sqlString">
      <value>
		INSERT INTO dbo.testTable (Id,Name)
        VALUES (@Id@Name@)
      </value>
    </property>
    <property name="sqlParams">
      <map>
        <entry key="Id" value="java.lang.String"/>
		<entry key="Name" value="java.lang.String"/>
      </map>
    </property>
</bean>
</beans>

I'm trying to do an insert using the Data Loader using the database connection object.

Thanks in advance for your help!
Best Answer chosen by IPFrampton
IPFramptonIPFrampton
I have since solved this myself. It was down to the '-' at the start of line 7 which fixed it. I've now got it inserting into the database as expected.