mysql - java.lang.RuntimeException: java.sql.SQLException: Field 'UserName' doesn't have a default value -
I am developing a web application ... which will be the list of users requesting registration ... We accept that all the details should be taken from the register table to enter the table ...
This is my servlet:
ClientApproveService = New ClientApproveService (); Approve.clientApprove ();
This is my service:
public class ClientApproveService {Public Zero Client Configure () {ClientApproveDAO cad = new ClientApproveDAO (); Datasource datasource = new datasource (); Cad.setDataSource (data source); Cad.insertClient (); }}
And this is my DAO:
public class ClientApproveDAO {Private Data Source Datasource; Public Zero SetDataSource (Datasource Data Source) {this.dataSource = DataSource; } Connection = null; Statement made = zero; Results set rs = null; Public Zero Insert Client () {try conn = dataSource.createConnection (); Prepared State Place ps = conn.prepareStatement ("Login, ID, Firstname, LastLameM, gender, category, dateofrth, age, address, country, state, city, postcode, email id, contact no, mobile number) Select); ps.executeUpdate ();} grip (eclipse e) {new runtime exception (E);} Finally {if (rs! = Null) try {rs.close ();} Grip (ignoring SQLException) {} Try (statement! = Zero) try {statement.close ();} hold (ignore SQLException) {} if try (conn! = Tap) {conn.close ();} hold (ignore SQLException) {}}}} < / Code>
this is my Register table:
to create table register (id int (100) zero not AUTO_INCREMENT primary key, first name varchar (300) default faucet, lastname varchar (300) default faucet, gender varchar (200) Default void, Category varchar (200) Default zero, DateOfBirth varchar (200) Default zero, Age int (3) Default faucet, Address communication (1000) Default faucet, Country variation (500) Default faucet, State Verb (500) ) Default faucets, City variants (500) Default faucets, Pincode int (10) De Olt tap Imelaid varchar (500) default NULL, no contact Varchar (20) default NULL, Mobile No varchar (20) default NULL);
And this is my login table:
Create the table login (username not vancar (100), password varchar (100) not id, id int (100) Faucet AUTONCRment Primary Key, FirstName Worm (300) Default Faucet, LastLike Worm (300) Default Null, Gender Worker (200) Default Nose, Category varchar (200) Default Faucet, DebtoffBrath Varchar (200) Default Faucet, Edge 3) Default faucet, et varchar (1000) default faucet, Country Vertex (500) Default Faucet, State Verb (500) D Fault null, city variant (500) default faucet, pincode int (10) default faucet, emailed variant (500) default faucet, contact nozz varchar (20) default faucet, mobile nocturnal (20) default null)
/ Pre>All the data from the Register table have to be entered in the table but I still have the username and password fields generated in the auto login table ... but I should be able to generate the rest right ??? But when I run it, this exception triggers.
java.lang.RuntimeException: java.sql.SQLException: Field 'Username' has no default value
Please contact me Please help ... decide in advance ....
You UserName
a vaule is filed, and it is not the default, try it:
Enter in login (id, first name, last name, gender, category, birth date, age, address , Country, state, city, pinco , Email id, contact no, mobile number, user name) *, from the 'undefined' register
Or, alternatively, you can do the ALTER
table Therefore, the default value is in the username
field:
Modify the optional table login Username varchar (100) zero default faucet;
Comments
Post a Comment