Question

I need to create dataSource in Java and I know that connection to this data base in C# looks like this:

SqlConnection connection = new SqlConnection("Data Source=exampleds;Initial Catalog=exampleic;Integrated Security=True");

I want to understand, how can I make the connection url from the data I have in C# code.

Was it helpful?

Solution 2

So, I've found answer to this question, connection url for this database would be:

jdbc:jtds:sqlserver://exampleds/exampleic;domain=???

Domain name described somewhere in web.config in C# application, driver for this connection would be

net.sourceforge.jtds.jdbc.Driver

So, DataSource would be...

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
    <property name="url" value="jdbc:jtds:sqlserver://exampleds/exampleic;domain=dName"/>
    <property name="username" value=""/>
    <property name="password" value=""/>
</bean>

Username and password I, personally, have known from administrator.

OTHER TIPS

Something like the following:

Connection connection = null;
connection = DriverManager.getConnection(
    "jdbc:oracle:thin:@localhost:1521:mkyong","username","password");

But you have to initialize JDBC driver first using code like this:

Class.forName("org.postgresql.Driver");

And I found this code using google during 3 seconds.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top