• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JPA show_SQL query

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

I am learning Spring boot, can some please let me know this property

spring.jpa.show-sql=true



i ave simple database connection with MYSQL using JDBC template, where data is getting inserted, but i want to see the query on console
so i have included the above statement but still nothing is visible on console.

Note: i am  not using Hibernate as of now.

also i noticed

spring.datasource.url=jdbc:mysql://localhost:3306/springbootdb
spring.datasource.username=root
spring.datasource.password=
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create-drop



among the above entries in application.properties file it is not taking username as root, so i got a error stating

"access to user ' '@localhost is denied for database 'springbootdb'


then in mysql i grant all privilege to all users then the error went and started inserting the data,
also i have used create-drop but the table is not getting dropped it is just updating.

please let me know is there anything is wrong. thanks.
 
Ranch Hand
Posts: 472
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I try add to properties application.properties:


also just one options


i get result that also show me sql

Hibernate: insert into journal (created, summary, title, id) values (?, ?, ?, ?)




A value of create-drop will create your tables, and then drop them when you close the sessionFactory.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic