Skip to content

Tag: spring-jdbc

Error while getting sql record using EntityManager

I am using EntityManager in spring boot app to get result from this query Its giving me correct output in PgAdmin but in java code List resultList = em.createNativeQuery(str).setParameter(1, sectionId ).getResultList(); Giving error ERROR: syntax error at or near “:” its breaking at data::jsonb .How do handle this using EntityManager. Answer You need to CAST like CAST( as jsonb)->>’product_id’ from

How to send the data finded in the controller to a view?

I try to do a java web application using: SpringBoot Mysql JDBC Design pattern: MVC, DAO And Thymeleaf I think i understood than: I must create a class for every Entity and a DAO classe who use the annotation @Repository: And create a controller like this where I use the method from the DAO: What i don’t understand:

What is the correct SQLException / spring data exception for missing permissions

I just noticed that when you try to execute a query that does not have required permissions (only tested on a mysql 5.7 database using the mysql-connector-java v8 driver) it is translated to a org.springframework.jdbc.BadSqlGrammarException. This is because the mysql driver itself throws a java.sql.SQLSyntaxErrorException. For instance: java.sql.SQLSyntaxErrorException: INSERT command denied to user ‘myuser’@’’ for table ‘mytable’ Is this correct

datetime conversion to Java in SQLServer 2016

I have a scenario where I have a table that has a date field with the datetime property. In the documentation ( : Note that java.sql.Timestamp values can no longer be used to compare values from a datetime column starting from SQL Server 2016. This limitation is due to a server-side change that converts datetime to datetime2 differently, resulting in