SQLException: Select statement throw exception The index 1 is out of range

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

SQLException: Select statement throw exception The index 1 is out of range



I tried connect to MS SQL Server but when i debut it and i get SQLException.



PreparedStatementCallback; SQL [select * from dbo.theLogin tl;]; The
index 1 is out of range


public ArrayList<Login> select(String username, String password)
JdbcTemplate select = new JdbcTemplate(dataSource);
return (ArrayList<Login>) select.query(
"select tl.username, tl.password from dbo.theLogin tl;",
new Object username, password,
new LoginRowMapper());



I cannot figure out what wrong it. Please help. Thanks in advancen





Tag the language that your code sample was taken from. The problem isn't in the SQL.
– Tab Alleman
yesterday





I"m using Java.
– peterwkc
50 mins ago




1 Answer
1



The second parameter to your query() call should be a list of values to use to bind to any variables in the SQL statement - but your SQL does not have any variables to bind to, so you get that "index 1 is out of range" when it tries to set the first parameter to the value of username. Your SQL looks like it will return a list of all username and password pairs from your table - which may not be what you were after...


query()


username






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

Executable numpy error

Trying to Print Gridster Items to PDF without overlapping contents

Hystrix command on request collapser fallback