I have an SQL method here. I would like to return the data in a String[] array. How do I do that exactly? Thank you! Answer You must define the array’s length and this can be done only after the Cursor fetches all the rows. Then set its length to the nimber of rows of the Cursor. Then inside the
Tag: java
SQL – How to return a list of data
I have this SQL method below, it is suppose to return multiple rows of data, but it is only returning one item every time I try to display the data. How do I fix that? Answer Inside the while loop in each iteration you change the value of LikeSong, so when the loop ends, LikeSong has the last value assigned
Load the ResultSet of query in dataframe using Spark / java
I want to load the Result Set of a select query in dataframe Spark. I’m using the following code : public static void func (Dataset df){ df.repartition(20); //one connection per …
Case condition in hql
What I’m trying to achieve with this query is: always do the “mother” conditional, but if there isn’t mother, then do the “dad” conditional, is this posible? Answer This query: will try to join first by matching the column idMother to :idMother. If this is not possible then…
Creating thread safe MyBatis sessions from a java.sql.Connection
I’m trying to use MyBatis with a Snowflake database. My situation is similar to that of this poster: Configure mybatis to use an existing connection Essentially, I can get a java.sql.Connection Object, but I cannot get that by way of a DataSource, or other steps normally done by RDBMS databases like Ora…
SQL / Hibernate insert only if url not exists
I have a list of urls and a table that contains urls. I want to only insert if the url is not in the table. After the insert the Data-table should be contain: My current attempt is to have a method findByURL(url):List and a call this method for every URL in the list. If the returned list is empty I
Subtract scanner value from sql table value
I’m trying to subtract a scanner input from a table value. Here’s a screenshot of my table: Here’s what my code looks like: The output of my code is: Here’s what I want my table to look like after subtracting 100 (my scanner input quantity): I’m unsure as to why subtracting my sc…
Are these SQL queries equivalent? And which is better or is there a better option?
I am working on a Spring web application that utilizes hibernate to connect to a DB2 database. I am try to optimize a service method that gets called may times during a wed service call by reducing …
Spring Data JPA – Custom Native Query-Methods list prints java.lang.Object
I have created a native custom query method: And calling EntityManager with: But all I get is: when I print out the list. Number of objects is correct so I assume something with casting is not correct. I do get a warning in my IDE: Why is this happening and how do I get the correct list? Answer You can
Apache Flink – External Jar
i’m trying to create a Flink application using maven and an extra dependency : com.microsoft.sqlserver mssql-jdbc</…