Hice una conexión mediante spring boot
y sin embargo me marca errores al momento de guardar junto con angular al dar save
me sale este error el problema es que al ejecutar postman
funciona correctamente la api
alguien sabe algo acerca de este problema no se por que cuando quiero guardar datos aparece este tipo de errores.
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'password' cannot be null at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.Util.getInstance(Util.java:386) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1040) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4120) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2503)
public Connection getConection(){
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/profiledb","root","root");
}catch (Exception e){
e.printStackTrace();
}
return con;
}
@Override
public int saveprofile(ProfileDto prof) {
int status=0;
try{
Connection con = getConection();
PreparedStatement ps = con.prepareStatement("insert into profileuser(name,user,email,number,password) values(?,?,?,?,?)");
ps.setString(1,prof.getName());
ps.setString(2, prof.getUser());
ps.setString(3,prof.getEmail());
ps.setString(4,prof.getNumber());
ps.setString(5,prof.getPassword());
status = ps.executeUpdate();
}catch (Exception f){
f.printStackTrace();
}
return status;
}
Y aquí les dejo el código de angular:
this.save = {
'id': '',
'name': this.name,
'user': this.user,
'email': this.email,
'number': this.number,
'password': this.password
};
this.getprofiles.getsave(this.save).subscribe(data =>{
console.log(data);
y mi html espero que puedan ayudarme
<div class="col-12 col-sm-6 movingpixel">
<h1 style="color: white">Register Here</h1>
<form>
<div class="form-group">
<label for="name">Name:</label>
<input type="text" class="form-control" id="name" aria-labelledby="namehelp" placeholder="" name="name" required [(ngModel)]="name">
</div>
<div class="form-group">
<label for="user">User:</label>
<input type="text" class="form-control" id="user" aria-labelledby="userhelp" placeholder="" name="user" required [(ngModel)]="user">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email" name="email" required [(ngModel)]="email">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="number">Numberphone:</label>
<input type="text" class="form-control" id="number" aria-labelledby="numberhelp" placeholder="" name="number" required [(ngModel)]="number">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" placeholder="password" name="password" [ngModel]="password" required >
</div>
<button type="submit" class="btn btn-primary" (click)="saveData()">Submit</button>
</form>
</div>
<div class="col-12 col-sm-6 movingpixel3">
<img class="imgsize" src="../../assets/img/register.png">
<h3 class="text-center newmargintop">Please Fill All The Fields</h3>
<p class="text-center" style="color: white">If you have any question please send any email to administrator</p>
<p class="text-center" style="color: red">Copyright: <a href="" style="color: white">@teamsolution.com</a></p>
</div>
</div>
</div>