Reputation: 23
Please advise how to make connection in java with SQL Server Windows authentication mode.
I'm working on NetBeans 8.1
Is below bean xml correct?
Here's my bean created for jdbc connection
<bean id="dataSource1"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="sun.jdbc.odbc.JdbcOdbcDriver" />
<property name="url" value="jdbc:sqlserver://DESKTOP-7CI6DU0\\SQLEXPRESS:1433;databaseName=master" />
<property name="username" value="" />
<property name="password" value="" />
</bean>
The error that I m facing is:
Compiling 6 source files to C:\Users\Nitish\Downloads\SMD\Spring_Batch_SendMail\build\classes
C:\Users\Nitish\Downloads\SMD\Spring_Batch_SendMail\src\SendMail\Mailitemwriter.java:58: error: cannot access DataAccessException
result += jdbcTemplate.update(UPDATE_QUERY, params);
class file for org.springframework.dao.DataAccessException not found Note: C:\Users\Nitish\Downloads\SMD\Spring_Batch_SendMail\src\SendMail\MailProg.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error C:\Users\Nitish\Downloads\SMD\Spring_Batch_SendMail\nbproject\build-impl.xml:929: The following error occurred while executing this line: C:\Users\Nitish\Downloads\SMD\Spring_Batch_SendMail\nbproject\build-impl.xml:269: Compile failed; see the compiler error output for details. BUILD FAILED (total time: 1 second)
Upvotes: 0
Views: 694
Reputation:
Your URL should look like this: jdbc:sqlserver://localhost\YourServerName:1433;databaseName=YourDatabaseName;integratedSecurity=true;
I haven't used Spring so I can only venture the following - you will need to add the user, but not the password as you are using Windows Authentication as opposed to Sql Server Mixed Mode authentication.
Upvotes: 1