|
-
June 7th, 2005, 01:45 PM
#1
JDBC and SQL server 2000
I need to pack my application that uses an SQL server 2000 DB and move it to a user's computer. My code is:
Code:
// Connection string
String conStr = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Video Club;User=VClub;Passwd=VClub";
public void NewCustomer(String firstName,
String lastName,
String phone,
String address) {
// SQL Query string
String query = "EXEC prc_NewCustomer N'" + firstName +
"', N'" + lastName + "', N'" + phone +"', N'" + address + "'";
try {
// Load the JDBC driver
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con = DriverManager.getConnection (conStr);
// Get a connection
Statement stmt = con.createStatement();
// Execute query
stmt.execute(query);
con.close();
}
catch(ClassNotFoundException esql){
esql.printStackTrace();
}
catch(SQLException esql){
esql.printStackTrace();
}
}
The problem with this code is that the user's computer should have sa with empty password. Is there a way to use Windows authentication? Or if not how should I add a user in SQL server wirh appropriate rights so that my application may use this login to connect?
Extreme situations require extreme measures
-
June 7th, 2005, 04:16 PM
#2
Re: JDBC and SQL server 2000
I don't think you can use Windows authentication for JDBC to SQL Server, you have to use SQL Server authentication. See http://support.microsoft.com/default...b;en-us;313100
You will need to use TSQL to create users on your users SQL Server if they do not already exist.
-
June 8th, 2005, 01:04 AM
#3
Re: JDBC and SQL server 2000
Thank you very much.
One SQL server related question: Can I create the user on that specific DB so that after backup(on my computer)-restore(on the user's computer) I would not have to create the user again?
Also do I have to grant exec access to my stored procedures only or is it smthng more that I need?
I have tried to create a user but I could not connect that's why I am asking...
Extreme situations require extreme measures
-
June 8th, 2005, 08:31 AM
#4
Re: JDBC and SQL server 2000
I'm not sure if users are sored in a backup (I would imagine so however). When ever I transfer a database, I usually end up creating a login with the command sp_addlogin (see http://msdn.microsoft.com/library/de..._adda_0q7i.asp)
-
June 8th, 2005, 08:37 AM
#5
Re: JDBC and SQL server 2000
Thanx again. If I don't manage to put it in the backup, I'll do it in a batch using sp_addlogin.
Extreme situations require extreme measures
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|