Skip to content
Advertisement

Tag: database-connection

Difference between connecting to a database using DriverManager and SpringBoot(Hibernate)

There are 2 ways to connect to a database when developing Java apps. Using DriverManager Connection conn = DriverManager.getConnection(url, name, password); // execute the query. Using application property file in SpringBoot spring.jpa.hibernate.ddl-auto=none spring.datasource.url=jdbc:mysql://localhost:5432/db_name spring.datasource.username=user spring.datasource.password=password Now you can use @Entity annotation on your class to put data into database. My question is how are these 2 ways different. If not

Configure a `DataSource` to connect to a managed Postgres server on Digital Ocean with SSL/TLS encryption

I am trying the managed database service on DigitalOcean.com, having created a Postgres instance. Digital Ocean defaults to requiring remote connections be made with SSL (actually TLS) encryption. How does one configure a JDBC DataSource implementation for providing connections to such a database server? This Question is similar to Produce a DataSource object for Postgres JDBC, programmatically but adds the

Checking connection to MySQL (Java)

I’m working on creating my little-utility for MySQL, and I need some help. How I can check connection to MySQL (by login and password), like it was realised in phpMyAdmin, without pointing some database at first. Because most of solutions for work with databases need exactly that pointing. Thanks in advance) Answer Yes. You can connect to the server without

What is the difference between OCI and THIN driver connection with data source connection between java and oracle XE?

I’m writing the below codes for connection between the java and Oracle 10g XE using 3 way(OCI, THIN and data source), the code is running successfully but don’t know difference between the THIN and OCI with data source connection. 1- 2- 3- Answer Oracle provides four types of drivers for their database, but I’ll only enumerate the two you asked

Why do I need Transaction in Hibernate for read-only operations?

Why do I need Transaction in Hibernate for read-only operations? Does the following transaction put a lock in the DB? Example code to fetch from DB: Can I use session.close() instead of tx.commit()? Answer Transactions for reading might look indeed strange and often people don’t mark methods for transactions in this case. But JDBC will create transaction anyway, it’s just

Advertisement