JDBC :: Accessing Sys Refcursor As PLSQL Out Parameter
Oct 13, 2009
The 11g jdbc guide gives and example of how to access a pl/sql function RETURNING a cursor. We have a stored proc that returns about 5 out parameters one of which is a SYS_REFCURSOR. This is different from RETURNING a ref cursor. How to pass a resultset object to the stored proc. I presume the same java declaration is required:
ResultSet cursor;
pass this as a parameter to the stored proc. I have listed the 11g JDBC sample code below:
In the preceding example:
• A CallableStatement object is created by using the prepareCall method of the connection class.
• The callable statement implements a PL/SQL procedure that returns a REF CURSOR.
• As always, the output parameter of the callable statement must be registered to define its type. Use the type code OracleTypes.CURSOR for a REF CURSOR.
• The callable statement is run, returning the REF CURSOR.
• The CallableStatement object is cast to OracleCallableStatement to use the getCursor method, which is an Oracle extension to the standard JDBC API, and returns the REF CURSOR into a ResultSet object.
calling a parameterized stored procedure in java jdbc from sql server.The stored procedure goes like this in sql
create proc patientreg @id int as begin select [patient_id],[Psurname], [pFirstname], [pMiddlename], [reg_date], [DOB], [Sex], [Phone_num], [Addr],[Email],[dbo].[fncomputeage](DOB) from [dbo].[Patient_registration] where [patient_id] = @id end please note dbo.fncompute(DOB) is a function
I was practicing my java skills and came across an exercise in which a non parameter constructor calls a two parameter constructor. I tried a few searches online but they all came back unsuccessful. This is the part I am working on:
public PairOfDice(int val1, int val2) { // Constructor. Creates a pair of dice that // are initially showing the values val1 and val2. die1 = val1; // Assign specified values die2 = val2; // to the instance variables. } public PairOfDice() { // Constructor that calls two parameter constructor }
I tried calling the two constructor using the line "this(val1, val2)" but I get an error because val1 and val2 are local variables.
Then I tried to use the same signature: "this(int val1, int val2)" but that didn't work either.
public class StudentJDBCTemplate implements StudentDao
above class giving error as
The type StudentJDBCTemplate must implement the inherited abstract method
StudentDao.listStudents()
Interface is as below
import java.util.List; import javax.sql.DataSource; public interface StudentDao { public void setDataSource(DataSource ds); public void Create(String Name,Integer age); public void getStudent(Integer id); public List<Student>listStudents(); public void delete(Integer id); public void update(Integer id,Integer age); }
I'm trying to understand the relationship between JAAS and JDBC..In WebSphere, when setting up a Dynamic cluster I have to first define the JAAS..Then, the datasource..The JAAS has one account/password and the datasource another..I'm not getting the relationship between needing both JAAS and JDBC docs.oracle.com/cd/E19225-01/820-5594/ahteo/index.html
@Transactional public long getSequenceSedeB(Long id) { BigDecimal seqValue = nu String sql = "SELECT MAX(ID) FROM SEDE_B_ALLEGATI_A WHERE ID_SEDE=:id"; SQLQuery query = getSession().createSQLQuery(sql);
[Code] ....
But it do not works; this is the log.
type.NullableType (NullableType.java:182) - could not read column value from result set: ID; Invalid column name
I have GameConsole class with gamePlay(). There are two objects in this class that I want to access from a class in another package.
package blackjackControls; public class GameConsole { Player dealer; //both of these objects I am trying to bring over into the blackjackGUI package Deck playingDeck; public void gamePlay(){
[code].....
The dealer and playingDeck objects are giving me an error of unresolved. the way it is written I also get a static error on line 37. I know that I have not yet written in the actionEvent statement in the button constructor.
What I want to do is this, this is my first class:
public class Footballer { int goals; String surname= ""; String team=""; private static int counter=0; private int dres; }
(this is just the header of the class... And this is my second class, which contains an ArrayList of the first class:
public class FootballTeam{ String teamname=""; String league=""; ArrayList<Footballer> f; }
And this is my third class which contains an ArrayList of the second class:
public class FootballLeague{ String leaguename=""; ArrayList<FootballTeam> ft; }
What I want to do is, know how many of footballers are there in the league? Meaning how many of "f"s are in the "ft"... I remember from C++ it was easy, you just did it something like this: ft.f[i]; (where i is a position), then you'd go through each of them, if you wanted to do something with them, or just ask for it's length, if you needed to know how much footballers are there.
I'm trying this method to get the size of the array in the 2nd class, from the 3rd class (containing an ArrayList of classes of 2nd class, but no luck:
int counter=0; for(int i=0;i<this.ft.size();i++) { counter+=this.ft[i].f.size(); }
I'm getting this: Array required, but ArrayList<FootballTeam> found ---
I've created a method to calculate the ratio of one vowel to another, but I was hoping to get some feedback on another way I could approach the problem. The first bit of code is to find the vowels and assign them to an array ( for me, it seemed the easier thing to do in order to easily access the data). In the other bit of code, I have a method with two arguments (the vowels) to calculate the ratio.
public void findVowels(StringBuilder message, String delimiter) { subString = message.toString().toLowerCase().split(delimiter); vowelCounter = new int[5][subString.length]; // Remove all whitespace for (int index = 0; index < subString.length; index++) { subString[index] = subString[index].replaceAll("s", "");
I do not think this is possible, but I'd like to confirm. If I have an HTML page that has an embedded Java applet, and that applet in turn renders an HTML document (within the applet window), is the HTML *within* the applet part of / accessible through the DOM for the parent page?
public class MyExample extends GCompound { //instance variables public GRect R1 = new GRect(0, 0, 20, 20); public GRect R2 = new GRect(0, 0, 5, 5); //R2 is in front of R1, but its coordinates are all "inside" of R1's coordinates //constructor public MyExample() { add(R1); add(R2); } }
1) Suppose I'm in a GraphicsProgram and declare:
MyExample myex = new MyExample();
Suppose I have coordinates (x1, y1), and want to find out whether this is the myex object defined in the previous line. I would use:
obj = getElementAt(x, y); if (obj == myex) (...and so on)
Now suppose I want to test whether the object is the GRect object R1 within myex. Why doesn't the following work?
if(obj ==myex.R1) (...and so on);
Here is the full code that shows my question; it outputs "myex", none of the other outputs come out...
I'm a total newbie to Java, and until now all I've done was draw some shapes and flags. I'm struggling to understand the code I've been given. I need to access values stored in an ArrayList within another class. Here are the two classes Seat and Mandate:
package wtf2; import java.util.*; public class Seat { public int index; public String place; public int electorate;
[Code] ....
The main class contains code that feeds data from 2 text files into Seat and Mandate. From there I managed to access the date in Seat (at the end):
package wtf2; import java.io.*; import java.util.*; public class CW2 { public static void main(String[] args)throws Exception {
[Code] ....
Now,instead of getting just the mp for Edinburgh South I need to get the vote values, compare them to each other, take the second biggest and display the associate party value. How to access data from that Array to get started at least.
I have an admin class that needs to access a method of another class and I'm unsure how to do it.
One of the methods in the admin class (DancerAdmin) accesses a .txt file with information in and each line is to be extracted and is to be created as an object of the Dancer class. The information in each line is to then be used to set the variables in the Dancer class.
To set the values the Dancer class has setter methods which I need to access each time a new object is created while cycling through the .txt file. I'm struggling to access these methods from the DancerAdmin class when I run the relevant method.
The snippet of code I have from the method in DancerAdmin is
while (bufferedScanner.hasNextLine()) { currentLine = bufferedScanner.nextLine(); lineScanner = new Scanner(currentLine); lineScanner.useDelimiter(","); dancer.add(new Dancer()); Dancer.setName(lineScanner.next()); mh_sh_highlight_all('java');
I get an error saying non static method setName cannot be referenced from a static content?
I currently have some code using a JFrame. I am trying to access the items in a JList to save them in a TXT file. For this, I am using a "for" loop. The problem is, is that when I try to access the list items, I can't access them. The way I am trying to access the items is by using:
BUT, I can't seem to get this to work. I tried to place this for loop everywhere and I can't access it. I tried accessing it under "public class Window", "private JFrame frmPcPartBuilder", "public static void main(String[] args)", "public void Initialize()" and I can't seem to access the JList. I basically have a save button that saves the list to a text file and the code I am trying to write is called by this button.
I have a HashMap returned from the server. There are two conditions
1. HashMap returned with only one set of key value pair or
2. HashMap with multiple set of data key value pairs.
Now in UI I have to display either text box or drop down box depending upon the size of map for that I am using length method
Java Code:
<c:choose> <c:when test="${fn:length(myDto.mayMapInDto) eq 1}"> display text box </c:when> <c:otherwise> display drop box </c:otherwise> </c:choose> mh_sh_highlight_all('java');
I can display drop box by looping but not sure how I can get only one element for text box. Tricky is I can't use key value to access since UI don't know what key will be returned.
I start my thread, it's for a real basic game I'm learning. Everything was working fine, until I got to recognizing keys. It runs, and I can close using the mouse on the close command, but the keys aren't being generated from the keyboard. I copied it to a working sample, and here are the two files.
The idea was to set the return value to true if any key is pressed, thus quitting, for this short sample program. Problem, it never recognizes any keys pressed on the keyboard. New to java and threading.
What I want to do is this, this is my first class:
Java Code:
public class Footballer { int goals; String surname= ""; String team=""; private static int counter=0; private int dres; } mh_sh_highlight_all('java');
(this is just the header of the class, just how it looks)...
And this is my second class, which contains an ArrayList of the first class:
Java Code:
public class FootballTeam{ String teamname=""; String league=""; ArrayList<Footballer> f; } mh_sh_highlight_all('java'); And this is my third class which contains an ArrayList of the second clas: Java Code: public class FootballLeague{ String leaguename=""; ArrayList<FootballTeam> ft; } mh_sh_highlight_all('java');
What I want to do is, know how many of footballers are there in the league? Meaning how many of "f"s are in the "ft"... I remember from C++ it was easy, you just did it something like this: ft.f[i]; (where i is a position), then you'd go through each of them, if you wanted to do something with them, or just ask for it's length, if you needed to know how much footballers are there.
I am trying to create a method in BlueJ which needs the values from a Map to be copied into a List so I can use the List methods min() and max(). Here is the method I have created so far:
public String findNamesInPageRange() { int minOfRange = Integer.parseInt(OUDialog.request("Input number for start of range")); int maxOfRange = Integer.parseInt(OUDialog.request("Input number for end of range")); String foundIt = null; for(String eachKey : bookIndex.keySet()) { List<Integer> pageList = new ArrayList<>(); //Cannot access values from a map using this List if((minOfRange >= Collections.min(pageList)) && (maxOfRange <= Collections.max(pageList))) { foundIt = eachKey; } } return foundIt; }
As can be seen there is a comment showing where my problem lies.
The Map is coded as Map<String, Set<Integer>> bookIndex = new TreeMap<>();
Ive tried using bookIndex.values() as the argument of the List but I get an incompatible type error
I am trying code a method where each key in a Map is iterated through keySet in a for-each loop but while each key is being accessed I need to also access its values where the values are of the type Set<Integer>. The Map is named bookIndex and I have tried using bookIndex.values() but this accesses all the values of the Map and not just the values of the key being presently accessed. Ive tried using a List to do this but was advised that this was not needed in another thread (Accessing Map values through a List). Ive tried creating a Set to contain these values but bookIndex.values() does not do it.
I'm working on an application and I would like to package my resources (icons, about dialog images, splash screen images, release version text, etc.) in the jar file I'm going to distribute for deployment. I would like to access these resources from the JAR file in my deployed code. But I would also like them accessible when I'm running the code in my Eclipse IDE. Is there a way to do this using only one code base?
My Eclipse project structure is src (folder) which contains my source code, bin (folder) which contains my class files and res (folder) which contains my resource files.
I am using the javapackager utility to create my deployment JAR and build a self-contained deployment .exe for deploying to Windows.
Is there a way to have the javapackager build a single JAR file from multiple sources (i.e. my bin and res folders)? What do I have to do in my code so that the same code can be used to load resources when I'm running in Eclipse and the self-contained deployment?