Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

preparedStatement compile error?

843838Aug 19 2006 — edited Aug 23 2006
Location.java:55: cannot find symbol
symbol  : method preparedStatement(java.lang.String)
location: interface java.sql.Connection
                        PreparedStatement passwordQuery = conn.preparedStatement
(
                                                              ^
1 error
package location;

import java.sql.*;
import java.io.*;
import java.util.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class Location {

	public String getFrmPin() { 
	//if (pin == null) {
	Context ctx = new InitialContext();
	DataSource ds= (DataSource) ctx.lookup("jdbc:mysql://localhost:3306/jobprop");
	Connection conn = ds.getConnection();
		try {
			PreparedStatement passwordQuery = conn.preparedStatement(
			"SELECT * FROM users WHERE username = ?");
			
		passwordQuery.setString(1, "abc");
		
		ResultSet result =  passwordQuery.executeQuery();
	} finally {
	conn.close();
	}
	}
}
anyone know why i can't compile? BTW i removed some of the .java code, in case it looks wierd.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 20 2006
Added on Aug 19 2006
10 comments
226 views