I need to pack my application that uses an SQL server 2000 DB and move it to a user's computer. My code is:
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?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(); } }




Reply With Quote