java.sql.SQLException: Parameter index out of range(1 > number of parameters, which is 0)

I have crated a java jframe program that allows you to input a csv file and then upload it to a local database however I am having trouble inserting all the data into the database. Any ideas on where I may be going wrong?

 try{
  BufferedReader br=new BufferedReader(new FileReader(filename1));
  String line;

  while((line=br.readLine())!=null){
  String[]value=line.split(",");//Seperator

filename1 is the selected csv file from a jFilechooser.

   String sql="insert into websitehistory (Date, URL, VisitCount) "
      + "values (?,?,?)";


  pst=conn.prepareStatement(sql);
  pst.setString(1, value[0]);
  pst.setString(2, value[1]);
  pst.setString(3, value[2]);  

Here is mysql query of inserting the separated values into the database

This is my table structure:

Date           Varchar(244)
URL            VarChar(244)
VisitCount     VarChar(244)

And the type of data I would like to insert is:

31/01/2014  15:26:00,  https://www.youtube.com/,  13
31/01/2014  15:25:00,  https://www.youtube.com/,  17

Any help is much appreciated

Answers


Try with this query

String sql="insert into websitehistory (Date, URL, VisitCount) "
      + "values (?, ?, ?)";

Need Your Help

Trying to populate a drop-down list with PHP & MySQL, mysql_fetch_assoc() error

php mysql drop-down-menu

I am trying to get a drop-down list to display column data containing countries ('level_4') but takes the value of the primary key ('id') for the form submission. I am migrating from an openoffice ...

stuck on nginx location directive

nginx webserver httpserver winginx

I am working on windows and using Winginx, modifying the nginx.conf file under conf folder. I have changed up the server block listening to port as follows:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.