Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- error: cannot find symbol PreparedStatement st = conn.prepareStatement("SELECT * FROM table WHERE name = ?");
- symbol: variable conn
- location: class splitString
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- class splitString{
- public static void main(String[] args){
- //Connect to database
- try
- {
- Class.forName("org.postgresql.Driver");
- Connection con=DriverManager.getConnection("jdbc:postgresql://localhost/database", "postgres", "pswd");
- if(con != null)
- System.out.println("Connection Successful!");
- }
- catch(Exception ee)
- {
- ee.printStackTrace();
- }
- String word = "Apples";
- PreparedStatement st = conn.prepareStatement("SELECT * FROM table WHERE name = ?");
- st.setString(1, word);
- ResultSet rs = st.executeQuery();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement