Skip to content

Tag: java

Create new PostgresSQL schema

What’s the easiest way to create a new Postgres scheme inside the database on the runtime and also, create the tables written inside a SQL file? This is a Spring boot application and the method receives the schema name that needs to be created for the db. Answer Although it sounds like this would be a c…

Display the total amount of each products below the table

I’m using itextpdf to display the sql query I was able separate the table according to PROD_NAME, and calculate the total amount of each products by getting the sum(amt) over(partition by prod_name) as total_amt from the sql query. Now, I’ve been trying to display the total amount of each products…

Is there a algorithm to resolve credit rating?

I need to implement a logic in either Java OR SQL for the following. There are credit ratings from numbers 1 to 11. And corresponding to each rating say x, I have 3 grades, effectively :x+, x and x-. Difference between each grade is termed as a step. For example, 2 and 2- is single(1) step,2+ and 2- is double…

How to fetch all data without the “out of range” SQL Exception?

I’m extracting data from a database, and I’m getting com.microsoft.sqlserver.jdbc.SQLServerException: The index 15 is out of range. during RunTime. My connection class is executed as the following: While I understand why it’s happening, in this while loop: I don’t quite understand how …

How can I get SUM result as an alias in MYSQL?

The code I wrote above results show like this. I want to know how to Sum numbers in the column ‘COUNTSVCE’. The column ‘COUNTSVCE’ is an alias of count(SVCE_DOMAIN). Rollup function might be a good solution but I can’t use it in my JAVA query so I get the result as alias. Thank y…