How do Tomcat Session, and Oracle Database connection interact with each other in a Java Spring web application? - spring

I am currently working on a Spring MVC web application that is hosted on a tomcat server and is connected to an Oracle database.
I would like to know in what cicumstances does the Tomcat user session or the oracle DB connection get refresed. For example, does refreshing the webpage refresh both sessions? Does doing an ajax call refresh one or both sessions? Will doing an static action on a webpage refresh the tomcat session, and not the oracle one? In general where can one session be refeshed, but not the other?
I know this can potentally vary between configurations, but I would like a general guideline on how these interactions works.

Related

How to configure database connection runtime in Spring Boot?

I made a new Spring Boot project using the Spring Initializr. I'm building an On-premise backend so what I'm trying to achieve is that when the user opens the jar executable and the server starts, he should be able to configure the database connection by going to localhost:8080/ in his web browser. Basically the index.html will have a form with 4 fields for IP Address, Database Name, UserName and Password. When the form is submitted spring will try to connect to the database with the provided information.
I have all my entities, repositories and controllers but currently the only way i can connect to a database is with the application.properties file, but since the user wont have access to the source, there should be a way for him to configure his database.
Thanks for your time!
I would suggest to use the Spring cloud Config server to store database related properties which is capable of picking up configuration at run time. Although it is typically configured with a Git repository, you can store them locally as pointed out in this thread.

How to store OAuth2 session into database and share it between Spring Boot servers

I want to create a solution based on that tutorial: https://www.baeldung.com/rest-api-spring-oauth2-angular
But it's not clear for me how several Spring Boot servers behind load balanced can share the same token session.
With session cookie the session data can be stored in MySQL and of server goes offline the session will be resumed by another Spring Boot server.
Can we have with OAuth2 the same setup with shared database so that the session data can be shared and switching of severs can be completely transparent for the end users?
Can we have with OAuth2 the same setup with shared database so that
the session data can be shared and switching of severs can be
completely transparent for the end users?
Yes, You just have to define a JdbcTokenStore and use it instead of the default InMemoryStore to store your OAuth tokens. The JdbcTokenStore must use a DataSource which is pointing to a MySQL Database.
Finally if you configure your Spring Boot apps to connect to the same MySQL Database to store Tokens by defining a DataSource you can get it working.
This post could be a good starting point.

How to Access H2 Database Created by Micronaut Application in Browser

During development of a Micronaut application I want to be able to check the H2 database. Normally when I've worked with H2 in Grails I am able to access a client through my browser but for Micronaut I can't seem to find a URL bound to the H2 client. I can see my database URL is jdbc:h2:mem:default.
Is there a way to view the H2 databse through my web browser when it is created in a basic Micronaut application?
This feature has not been implemented. Please file an issue if you would like it to be in the future

how to get tomcat session attribute from oracle

I have a web application made using Oracle Apex that implements the session management itself transparently, and I have implemented two-way SSL configuration in tomcat.
So my basic configuration is following
database: oracle 11g
application server: tomcat 7
apex 5.1
Now I need to add a token-based authentication so I have added a filter in the "ORDS" (Oracle Rest Data Service) configuration files and added a Java class. Now I have my token attribute added to the tomcat sessions:
But I need to access those attributes from inside my Oracle Database (in Java or PL/SQL) so I can do the authentication with it.
The Session.getAttribute doesn't seem to work there because all I have (sent via cookie) from tomcat session is just its jsessionid

Who maintain the session - Is it application framework or application server?

I am curious, for example, when I use spring framework on tomcat server , who actually maintain the session. In other word, does spring itself have their own mechanism/logic to maintain the session, or does it delegate the session maintenance to the tomcat server?

Resources