inserting input into mysql using netbeans

Alles, was MariaDB und MySQL betrifft, kann hier besprochen werden.

inserting input into mysql using netbeans

Postby shaf » 29. October 2014 09:23

hi. i'm still a newbie at this so i am hoping for some help please..
i am using xampp with netbeans for my project. i wrote my coding using jsp page, but when i run the page and submit, it gives out this output:
"java.sql.SQLException: Field '5' doesn't have a default value".

the field that the error pointed out is the field that i didn't include in my jsp page, but field 5 is available in my database. what should i do? i'm sorry if i explain it confusingly..i give an example of my project:
database abc: columns: 1,2,3,4,5
then in my jsp coding, i wrote:

PreparedStatement ps= connection.prepareStatement("INSERT INTO abc(1,2,3,4)" + "VALUES (?,?,?,?)");

where did i go wrong? is it wrong because i didn't include all variables in the database in the jsp page? so do i have to change the coding or do i have to change the database columns? any help is so much appreciated.
shaf
 
Posts: 3
Joined: 29. October 2014 08:49
Operating System: Windows 7

Re: inserting input into mysql using netbeans

Postby Nobbie » 29. October 2014 10:40

shaf wrote:is it wrong because i didn't include all variables in the database in the jsp page?


Exactly, your table contains 5 columns, your code only 4. In that case, usually a "Default value" is assigned to the missing column - but there is no default value specified for column 5 in your table (this is done in the CREATE TABLE statement), and thats what the error message says. Therefore you cannot ommit that column.
Nobbie
 
Posts: 8772
Joined: 09. March 2008 13:04

Re: inserting input into mysql using netbeans

Postby shaf » 29. October 2014 11:48

thank you :) actually, my plan is to access the missing field in the forwarding jsp page..is it possible to do that with a certain coding? hehe if it isn't possible, so i have to do a different database, is it? is it alright if i call multiple select statements in one page?
shaf
 
Posts: 3
Joined: 29. October 2014 08:49
Operating System: Windows 7

Re: inserting input into mysql using netbeans

Postby Nobbie » 29. October 2014 12:28

shaf wrote:is it possible to do that with a certain coding? hehe if it isn't possible, so i have to do a different database, is it? is it alright if i call multiple select statements in one page?


It should be possible, but anyway, this not the right forum for you. First of all, it is a german board ("Grundlagen und Wissenswertes"), at next it is not a JSP neither a Netbeans board. Finally a forum cannot replace the need of reading documentation and tutorials. You will find lots of tutorials out in the WWW.
Nobbie
 
Posts: 8772
Joined: 09. March 2008 13:04

Re: inserting input into mysql using netbeans

Postby shaf » 29. October 2014 13:19

sorry n thank you..>.<
shaf
 
Posts: 3
Joined: 29. October 2014 08:49
Operating System: Windows 7


Return to MariaDB - MySQL

Who is online

Users browsing this forum: No registered users and 1 guest