This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Basic SQL Server JDBC problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Basic SQL Server JDBC problem" Watch "Basic SQL Server JDBC problem" New topic
Author

Basic SQL Server JDBC problem

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1043
I connect to a SQL Server database called "Calendar" with a string like this:
"jdbc:microsoft:sqlserver://DellPC:1433;"+
"Database=Calendar;User=test;Password=test";
(Note I specify the database here -- Calendar)
Then, after making sure the permissions are correct (can log into the calendar database from Query Analyzer and do a select on the same table the code below tries to do), I try to do a select on the users table in this database like this:
SQL = "SELECT COUNT(*) as Count FROM " +
"users where use_loginID = " + login + " AND " + "use_password = " + password +";";
(login and password values came from an HTML form)
However, when I executeQuery() I get the error:
"Invlid Object name users".
Any ideas what's wrong here?
Thanks in advance.
-- Mike
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Basic SQL Server JDBC problem
 
Similar Threads
encrypt password on login form?
i need help on loggin account limit
SQL injection?
Java Beans and JSP
ResultSet