'could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet with oauth
I am doing a rest service with java spring boot. The tables are created correctly in the database and locally test everything works correctly, but when I mount the .war in a tomcat in my vps the Fail starts.
Doing a POST request to /oatuh/ token to login throws me an exception:
"could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet"
User Entity:
@Entity
@Table(name = "users")
public class UserEntity implements Serializable {
/**
*
*/
private static final long serialVersionUID = -7125479784396028079L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_id")
private Long id;
@Column(name = "username", unique = true)
private String username;
@Column(name = "password")
private String password;
@Column(name = "email", unique = true)
private String email;
DAO:
@Repository
public interface UserDao extends JpaRepository<UserEntity, Long>{
@Query("select u from UserEntity u where u.username = ?1")
public UserEntity findByUsername(String username);
}
Service:
@Override
@Transactional(readOnly = true)
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
UserEntity user = userDao.findByUsername(username);
System.out.println(user);
if (user == null) {
log.error("El usuario no existe en la base de datos.");
throw new UsernameNotFoundException("Usuario inexistente en la base de datos");
}
return new User(user.getUsername(), user.getPassword(), true, true, true, true, null);
}
Solution 1:[1]
Resolved! I couldn't see the error when my app was on Tomcat. I tried Postman and the mistake was that the authorities could not be null, if or if you need a role.
Solution 2:[2]
@Column(name = "lastModifiedBy")
private int lastModifiedBy;
@Column(name = "lastModifedOn")
private Date lastModifiedOn;
There was a typo in my code lastModifedOn
, I changed it to lastModifiedOn
and the issue was fixed forever.
Solution 3:[3]
Sometimes happens with database queries, in query, the cause of the error is: the database to which the table is built is different from the database to which the configuration file is connected, and the address of the database to which the table is built is not checked carefully.
You must add scheme, example: myScheme.myTable. greetings..
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Juance |
Solution 2 | Ä°smail Y. |
Solution 3 |