Resultset.next() is not moving ahead after fetching 2.14B records out of 2.5B records and exists out after long time
I am fetching records from Oracle 12c using JDBC driver. I have total 2.5B records, after successful fetching 2.14B records (2147483000), rs.next() got stuck and not moving ahead and exists out after a long time. I am fetching this data from a simple Hash partitioned table having 2000+ child partitions having a single NUMBER data typed column. Also, I do have sufficient memory on my machine.
suggestions/ideas anyone?
See also questions close to this topic
-
Case 3 will not execute
import java.util.Scanner;
public class Lab4 {
public static void main(String[] args) { // Declare some variables you need // --> Scanner scan = new Scanner(System.in); int endOption = 4; int chosenOption = 0; int countTo = 0; int factorialCount2 = 0; int lefty = 0; do { // Display the menu displayMenu(); // Ask the user for one option // --> chosenOption = scan.nextInt(); switch (chosenOption) { // Define four cases for different options. Don't forget "break". // --> case 1: System.out.println("Enter a number: "); countTo = scan.nextInt(); calcSum(countTo); break; case 2: System.out.println("Enter a number: "); factorialCount2 = scan.nextInt(); factCont(factorialCount2); break; case 3: System.out.println("Enter a number: "); lefty = scan.nextInt(); leftmostDig(lefty); break; case 4: System.out.println("Bye"); break; } } while (chosenOption<endOption); scan.close(); } /** * Print the menu */ private static void displayMenu() { System.out.println("Please choose one option from the following menu:"); System.out.println("1) Calculate the sum of integers from 1 to m"); System.out.println("2) Calculate the factorial of a given number"); System.out.println("3) Display the leftmost digit of a given number"); System.out.println("4) Quit"); } private static int calcSum(int addingTo){ int sum = 0; for(int i=1;i<=addingTo;i++){ sum = sum + i; } System.out.println("The sum of 1 to " + addingTo + " is " + sum); System.out.println(); return sum; } private static int factCont(int number){ int multiply = 1; for(int i=1; i<=number; i++){ multiply = multiply * i; } System.out.println("The factorial of " + number + " is " + multiply); System.out.println(); return multiply; } private static int leftmostDig(int num){ int finalized = 0; while(num >=10){ finalized = num/10; } System.out.println("The leftmost digit of " + num + " is " + finalized); System.out.println(); return num; }
}
So, yes this is a lab I am doing for school.. the only one that will not execute is case 3. I am not sure what exactly is happening. I tried this while I was at work on an online compiler and it worked. Now when I transfer it to the actual program I run into a snag. Let me know what you think it might be as I am very perplexed by what could be.
-
Can anyone help me with my school project where i have to make a math Quiz?
I need to find a way where the user can enter decimal numbers not only whole numbers for the division part and I also need help to fix the multiplication part, it keeps displaying the wrong answer when I intentionally wrote the wrong answer, for me it kept saying "the correct answer is 140" when the question was 5 x 2, and when I write 10 it says its correct but if its the same question and I write 4, for example, is says wrong the correct answer is 140 to the 5 x 2 question please help? here's my full code, and please if you find any more mistakes I did please let me know.
public static void main(String[] args) { String name = JOptionPane.showInputDialog(null, "Please enter your name"); JOptionPane.showMessageDialog(null, "Hello " + name + "\nWelcome to your Math Quiz (no calculators allowed) \nPlease answer the following questions"); int randVal1 = (int) (20 * Math.random()) + 1; int randVal2 = (int) (20 * Math.random()) + 1; int randomNumberAdd = randVal1 + randVal2; int randomNumberMul = randVal1 * randVal2; int randomNumberDiv = randVal1 / randVal2; int correct = 0; for (int i = 1; i < 10; i++) { String userAnswer = JOptionPane.showInputDialog(null, randVal1 + " + " + randVal2 + " = "); int answer = parseInt(userAnswer); if (answer == randVal1 + randVal2) { JOptionPane.showMessageDialog(null, "Correct!"); correct++; } else if (answer != randVal1 + randVal2) { JOptionPane.showMessageDialog(null, "Incorrect!"); JOptionPane.showMessageDialog(null, "The correct answer is " + randomNumberAdd); } { randVal1 = (int)(20* Math.random()) + 1; randVal2 = (int)(20*Math.random()) + 1; String userAnswerMul = JOptionPane.showInputDialog(null, randVal1 + " x " + randVal2 + " = " ); int answer2 = parseInt (userAnswerMul); if (answer2 == randVal1 * randVal2){ JOptionPane.showMessageDialog(null, "Correct"); correct++; } else if (answer2 != randVal1 * randVal2){ JOptionPane.showMessageDialog(null, "Incorrect"); JOptionPane.showMessageDialog(null, "The correct answer is " + randomNumberMul); } { randVal1 = (int) (10 * Math.random()) + 1; randVal2 = (int) (10 * Math.random()) + 1; String userAnswerDiv = JOptionPane.showInputDialog(null, randVal1 + " ÷ " + randVal2 + " = "); int answer3 = parseInt(userAnswerDiv); if (answer3 == randVal1 / randVal2) { JOptionPane.showMessageDialog(null, "Correct!"); correct++; } else if (answer3 != randVal1 / randVal2) { JOptionPane.showMessageDialog(null, "Wrong!"); JOptionPane.showMessageDialog(null, "The correct answer is " + randomNumberDiv); } { } } } } JOptionPane.showMessageDialog(null, "You got " + correct + " correct answers."); } }
-
trying to importing ItemView class ends up MenuView class
I am trying to write an adaptery to fetching data from TMDB API.
import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.example.myapplication.MovieModelClass; import java.util.List; public class Adaptery extends RecyclerView.Adapter<Adaptery.MyViewHolder> { private Context mContext; private List<com.example.myapplication.MovieModelClass> mData; public Adaptery(Context mContext, List<MovieModelClass> mData) { this.mContext = mContext; this.mData = mData; } @NonNull @Override public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View v; LayoutInflater inflater=LayoutInflater.from(mContext); v=inflater.inflate(R.layout.movie_item, parent, false); return new MyViewHolder(v); } @Override public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { holder.title.setText(mData.get(position).getTitle()); holder.releaseYear.setText(mData.get(position).getReleaseYear()); holder.genre.setText(mData.get(position).getGenre()); } @Override public int getItemCount() { return 0; }
when i try to write this code with following a tutorial gives error for this part, by making ItemView red in
title = ItemView.findViewById(R.id.title_txt)
parts.public static class MyViewHolder extends RecyclerView.ViewHolder{ TextView title; TextView releaseYear; TextView genre; ImageView image; public MyViewHolder(@NonNull View itemView) { super(itemView); title = ItemView.findViewById(R.id.title_txt); releaseYear = ItemView.findViewById(R.id.releaseYear_txt); genre = ItemView.findViewById(R.id.genre_txt); image = ItemView.findViewById(R.id.imageView); } } }
When I try to fix it by importing class it imports
import androidx.appcompat.view.menu.MenuView;
after importing this still does not work. This time:title = MenuView.ItemView.findViewById(R.id.title_txt);
findViewById
is being red.I did not get what is wrong. I tried to do Refactor>>Migrate to Android.x but didn't help. Can someone help me with that?
-
Spring Boot JPA with Hibernate Spatial and an Oracle DB using gradle I can't get the dependency included
I'm trying to use Hibernate-spatial with a spring boot application. I'm upgrading existing code that was using the 1.1.1 version of the hibernate-spatial library and hibernate-spatial-oracle library. It "works" but brings in an older version of hibernate (3.2.2) in addition to the 5.3.9 version that spring-boot is using. This causes some other conflicts with dependencies. I want to upgrade to user the matching hibernate-spatial-5.3.9 but when I add it as a dependency gradle doesn't put it on the classpath and building the springboot jar fails saying it can't find the jar. The jar exists in the gradle cache but it never shows up on the eclipse classpath.
Seems that using: implementation 'org.springframework.boot:spring-boot-starter-data-jpa' brings in a lot dependencies not sure if there's an easier way to include the spatial dependency or why there seems to be a silent failure when I just declare it.
-
Do you still get JCE Policy if you use the JDK java bin instead of the JRE (inside the JDK) java bin?
For Java - you can download the Cryptography Extensions here. (JCE)
You place these (in the JDK) into
/jdk-8.../jre/lib/security/
. (They replace 2 3Kb files with 6Kb files).Inside the JDK there are (at least) two Java bin files:
/jdk-8.../bin/java /jdk-8.../jre/bin/java
Now I want to use these JCE extensions for my Java application.
It seems to me that if you use
/jdk-8.../bin/java
you won't use the JCE extensions, but if you use/jdk-8.../jre/bin/java
then you will. Is that correct?My question is: Do you still get JCE Policy if you use the JDK
java
bin instead of the JRE (inside the JDK)java
bin?Assumptions:
- This is Oracle Java
- This is JDK 8
- This is running on Red Hat.
-
Can you replace multiple pattern matches from one string using regexp_replace?
Here is a sample string: Year,Quarter,Month,text1,text2,Department,BU,text3,text4,Job,Grade,Pay,Location,text5,text6,
I need to remove all occurrences of the random texts. Rules are:
- The random texts always come in a pair, one after another.
- The first of the two texts always begin with the word “namesa” however the length is unpredictable, but the second one follows no such pattern. Example, text1 could be “namesa-their duty 505”, text3 could be “namesa-silver lane near me”, text5 could be “namesa-regexp 101 challenge”. Text2, text4, text6 are completely unpredictable.
- None of these texts contain a comma. They only end in a comma.
- The number of times this whole pattern repeats is unpredictable.
select ('Year,Quarter,Month,namesa-their duty 505,text2,Department,BU,namesa-silver lane near me,text4,Job,Grade,Pay,Location,namesa-regexp 101 challenge,text6,') from dual;
For the above input, my output should be: Year,Quarter,Month,Department,BU,Job,Grade,Pay,Location,
Basically, we need to locate the word “namesa” - start from there, go through two commas, remove everything from namesa through the second comma, then repeat the same thing again for the rest of the string. I am at a loss how to do this in regular expressions.
-
How to take take user input in JDBC for a Statement?
Here is my JDBC code, I'm trying to take user input for a SQL statement via the console:
import java.sql.*; public class Aufgabe_6_2 { public static void main(String [] args) { String searchTerm = "a"; try { Connection conn = DriverManager.getConnection("jdbc:mariadb://slo.swe.th-luebeck.de:3306" + "/Gruppe18?user=Gruppe18&password=xxxxxx"); PreparedStatement stmt = conn.prepareStatement("select kd_Nr, name From Kunde WHERE name LIKE ? group by kd_Nr"); stmt.setString(1,"%" + searchTerm + "%"); ResultSet res = stmt.executeQuery(); while (res.next()) { System.out.println(res.getInt("kd_Nr") + ", " + res.getString("name")); } } catch (SQLException e) { System.out.println(e.getMessage()); } } }
In this case, I already wrote my own SQL statement, but now I want to delete my own SQL statement and take the statement from the user input.
-
how to convert String to java.sql.Date?
I need to convert a string in the format i.e. "jan 25,2021" to a java.sql.date in the format "2021-01-25". I tried to use this code:
String date = "jan 25,2021"; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); java.sql.Date booking_date=null; try{ java.util.Date util_date = format.parse(date); booking_date = new Date(util_date.getTime()); } catch(ParseException e){ System.out.println(e); }
But always throws a ParseException. Where is the mistake?
-
Executing stored procedure in Java class
I have a stored procedure that I want to execute within a Java class. I have the values of the stored procedure within the SQL of the procedure and want to be able to execute it fully in a Java class.
Below is the stored procedure:exec @sta = storedProcedureName @TFT = 'Value', @TFTRW = 'Value2', @TRTF_Num = 1,
Since I already have the full statement I tried to execute it using a prepared statement but got the below error:
must declare variable @sta
Does anyone know how I can just execute the stored procedure above in my class or do I have to prepare a callable statement and substitute the values in as Strings and Ints?