943,604 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 558
  • MySQL RSS
Sep 16th, 2009
0

stmt from db_connect tutorial isn't working

Expand Post »
Topic
The topic of this question is: db_Connect does not connect.
Hello and Thank you in advance for any assistance.


System info:netbeans project,database attached or provided at:
http://cid-b5cb457363230793.skydrive...lic/school.zip



The purpose of this post is: Try to get a sql statement to work



The functionality of this code is:
MySQL Syntax (Toggle Plain Text)
  1. · "SELECT u.uid, firstName, lastName, address1, address2, city, postCode, email, phone, ug.groupName as userGroup "
  2. · +"FROM user u, usergroup ug WHERE uid='"+userName+"' AND password='"+password+"' AND groupName IN"
  3. · +" (SELECT groupName FROM usergroup WHERE groupid =(SELECT groupid FROM usergroup_mapping WHERE uid=u.uid))";



My question concerning this code is:
What is wrong with the sql statement provided in tutorial. Or a description of its function .



The errors related to this code are:
MySQL Syntax (Toggle Plain Text)
  1. Initializing Sun's JavaServer Faces implementation (1.2_04-b22-p05) for context '/school'
  2. Initialize <------------>jdbcDriver<------------>
  3. 12345678<------------>12345678
  4. SQLException:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'user u,usergroup ug WHERE uid='12345678' AND password='12345678' AND groupName I' at line 1
  5. Error on DB return
  6. java.lang.NullPointerException
  7. at servlets.LoginServlet.doPost(LoginServlet.java:82)
  8.  



Note:
I was told to add table qualifiers to the where clause.
What does this mean. Maybe if someone could break down what the statement is saying (laymens terms) I could fix it.



Thanks again.
-ceyesuma
Similar Threads
Reputation Points: 7
Solved Threads: 2
Posting Pro
ceyesuma is offline Offline
524 posts
since Aug 2007
Sep 17th, 2009
0

Re: stmt from db_connect tutorial isn't working

Topic
The topic of this question is: db_connect+my stmt
Hello and Thank you in advance for any assistance.


System info:

Noted in previous post.


The purpose of this post is:

Display supplied stmt from above mentioned tutorial. Stmt throws an error as noted in previous post.

Display my new stmt.



Code description:supplied stmt

MySQL Syntax (Toggle Plain Text)
  1. "SELECT u.uid, firstName, lastName, address1, address2, city, postCode, email, phone, ug.groupName as userGroup "
  2. +"FROM user u, usergroup ug WHERE uid='"+userName+"' AND password='"+password+"' AND groupName IN"
  3. +" (SELECT groupName FROM usergroup WHERE groupid =(SELECT groupid FROM usergroup_mapping WHERE uid=u.uid)
  4.  

Code description: my new statement

MySQL Syntax (Toggle Plain Text)
  1. String strQuery = "SELECT u.uid, u.password,ug.groupName FROM user AS u,usergroup AS ug,usergroup_mapping AS ugm WHERE u.uid='userName' AND u.password='password' AND u.uid=ugm.uid AND ugm.groupid=ug.groupid";



My question concerning this code is:

If my new stmt produces the required field when I run it on the databases. Why doesn’t the login except username=10101010 password =StealthProject which is in the data base?


The errors related to this code are:
my new stmt:

MySQL Syntax (Toggle Plain Text)
  1. Initializing Sun's JavaServer Faces implementation (1.2_04-b22-p05) for context '/school'
  2. Initialize <------------>jdbcDriver<------------>
  3. 10101010<------------>StealthProject
  4. Error on DB return
  5. java.lang.NullPointerException
  6. at servlets.LoginServlet.doPost(LoginServlet.java:82)
  7.  

Thanks again.
-ceyesuma
Reputation Points: 7
Solved Threads: 1
Light Poster
ceyezumma is offline Offline
30 posts
since Sep 2009
Sep 17th, 2009
0

Re: stmt from db_connect tutorial isn't working

logged.#23334
Reputation Points: 7
Solved Threads: 2
Posting Pro
ceyesuma is offline Offline
524 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: Two table troubles
Next Thread in MySQL Forum Timeline: Encrypt and decrypt an existing column





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC