Problem in storing of the resultset in vector
i'm using Vectors to store the data which i got from the resultsets. all that is working fine. i display this data in a vector in a JComboBox. but my method is resetting the vector itself eventhough i'm not touching it at all. the code is as follows
int in=canteen_text.getSelectedIndex();
System.out.println(item_description[in]);
for(int i=0;i<10;i++)
item_name.removeAllItems();
for(int j=0;j<item_description[in].size();j++)
item_name[i].addItem(item_description[in].elementAt(j));
item_name[i].setSelectedIndex(0);
here canteen_text is a JComboBox,
item_description[] is my array of vectors
item_name[] is my array of JComboBox
i still can't understand how this code is resetting item_description[0].
plz help!!!
Don't cross-post:
http://forum.java.sun.com/thread.jsp?thread=472970&forum=424&message=2188783
http://forum.java.sun.com/thread.jsp?thread=472969&forum=57&message=2188781
http://forum.java.sun.com/thread.jsp?thread=472968&forum=422&message=2188779
http://forum.java.sun.com/thread.jsp?thread=472966&forum=31&message=2188776
http://forum.java.sun.com/thread.jsp?thread=472932&forum=48&message=2188536
MOD
Similar Messages
-
Problem in storing of the resultset in vector and updating comboboxes
i'm using Vectors to store the data which i got from the resultsets. all that is working fine. i display this data in a vector in a JComboBox. but my method is resetting the vector itself eventhough i'm not touching it at all. the code is as follows
int in=canteen_text.getSelectedIndex();
System.out.println(item_description[in]);
for(int i=0;i<10;i++)
item_name.removeAllItems();
for(int j=0;j<item_description[in].size();j++)
item_name[i].addItem(item_description[in].elementAt(j));
item_name[i].setSelectedIndex(0);
here canteen_text is a JComboBox,
item_description[] is my array of vectors
item_name[] is my array of JComboBox
i still can't understand how this code is resetting item_description[0].
plz help!!!Don't cross-post:
http://forum.java.sun.com/thread.jsp?thread=472970&forum=424&message=2188783
http://forum.java.sun.com/thread.jsp?thread=472969&forum=57&message=2188781
http://forum.java.sun.com/thread.jsp?thread=472968&forum=422&message=2188779
http://forum.java.sun.com/thread.jsp?thread=472966&forum=31&message=2188776
http://forum.java.sun.com/thread.jsp?thread=472932&forum=48&message=2188536
MOD -
How to access parameters from an object stored in a shopping-cart vector?
Hello;
I am writing some code that will be part of a website that will have the
ability to allow customers to place items into a shopping cart and then
purchase them.
The way that the shopping cart works is that a products page is displayed on the website that has 'add' buttons on it next to each product on the page.
When the customer clicks the 'add' button next to a particular product to purchase it, the code performs a query of a products database table for the numeric product id linked to the 'add' button they clicked.
When the product id is found, the query then loads the
product information for it from the DB table columns into the shopping cart
Vector as an object in the form of a result set string. This object contains
the parameters that define the product, i.e. product_id, product_quantity,
date_ordered, ship_status and so on.
In the code, when the customer is done shopping and clicks on a button
labelled 'place order', I want the code to access the shopping cart Vector
and extract each item object from the cart. I then want the code to be able
to get from each item object, the parameters that make up each item as
described above and take the values stored in each of the parameters and
store them in variables. Finally I want to take those variables and write
them to an orders DB table in the proper columns via a query.
I have tried researching information on Vectors to see if I could find out a way to do this but the little information that I located did not give me a clear idea
of how to go about writing the code, it only seemed to suggest a vague,
rough idea as to how it might be done. I am relatively new to Java
programming and so don't have any experience working with Vectors.
I have enclosed the code below that shows how the items are being stored in the shopping cart Vector. Can anybody tell me how I could go about writing the code that will extract the items from the shopping cart as described above in a servlet? Any assistance you can give me will be greatly appreciated.
Thank you!
String productID = request.getParameter("productID");
String qty = request.getParameter("qty");
Vector cartlist = new Vector();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
java.sql.Connection conn = java.sql.DriverManager.getConnection("jdbc:odbc:website", "", "");
java.sql.Statement st = conn.createStatement();
String query = "SELECT productID, productName, productCategory,
productPrice from Products WHERE productID ='" + productID + "'";
java.sql.ResultSet rs = st.executeQuery(query);
while(rs.next()){
cartlist.addElement(rs.getString("productID") + " " +
rs.getString("productName") + " " +
rs.getString("productCategory") + " " +
rs.getString("productPrice") + " " + qty);
} catch(SQLException sqlex){
} catch(Exception e){
}//Try Changing your code this way.
String productID = request.getParameter("productID");
String qty = request.getParameter("qty");
Vector cartlist = new Vector();
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
java.sql.Connection conn = java.sql.DriverManager.getConnection("jdbc:odbc:website", "", "");
java.sql.Statement st = conn.createStatement();
String query = "SELECT productID, productName, productCategory, productPrice from Products WHERE productID ='" + productID + "'";
java.sql.ResultSet rs = st.executeQuery(query);
while(rs.next())
String productID = rs.getString("productID");
String productName = rs.getString("productName");
String productCategory = rs.getString("productCategory");
String productPrice = rs.getString("productPrice");
String productID = rs.getString("productID");
cartlist.addElement(new AddCardElement(productID, productName, productCategory, productPrice, productID, qty));
//class AddCardElement should be there in your application
catch(SQLException sqlex)
catch(Exception e)
//you have to add a new class AddCardElement like this
class AddCardElement
public String m_productID;
public String m_productName;
public String m_productCategory;
public String m_productPrice;
public String m_productID;
public GenerateLocationData(String productID, String productName, String productCategory, String productPrice, String productID, String qty)
m_productID = productID;
m_productName = productName;
m_productCategory = productCategory;
m_productPrice = productPrice;
m_productID = productID;
}//-Achyuth B -
Traversing thru the resultset(urgent)
Hi,
I need help on traversing thru the resultset. My actual problem is i have more than 100 rows returned by the query so i have to display 10 records per page, for that i have to implement the
First | Next options so that to traverse thru the resultset.
So anybody who has done it earlier please help me out. It would be kind enough, if you post the code sample.
Thanks in advance,
Raj.If you are using JDBC2.0 compliant driver, it is very simple. You can traverse using
rs.relative(int) method.
rs.relative (10) moves your pointer to 10 records down.
rs.relative(-10) moves your pointer 10 records up.
If you do not have JDBC2.0 cpmpliant driver, yo can take the resultset in vector and traverse it using a loop.
Cheers
Sekar. -
Problem in setting the resultset recordset
hi all,
i am trying to do paging in my website .. i want to set the records fetched from the resultset...i am using the "rs.setFetchSize(3)"
i want to show only 3 records per page...
code is shown below.. problem is it is showing
"java.sql.SQLException: Invalid Fetch Size"
exception.... please help me out...
package demo;
import java.sql.*;
public class fetchrecord {
public static void main(String[] args) {
Connection con =null;
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:chandan");
Statement st=con.createStatement();
String q1="Select * from Table1";
ResultSet rs=null;
rs=st.executeQuery(q1);
rs.setFetchSize(3);
System.out.println("Details are as follows");
System.out.println("\n");
while(rs.next())
String Name = rs.getString(1);
String School = rs.getString(2);
System.out.print(Name+" ");
System.out.print(School);
System.out.println("\n");
}catch(Exception e)
System.out.println(e);
try {
con.close();
catch (SQLException e)
e.printStackTrace();
thanks
chandan sharmaas per the api documentation, an exception occurs when the condition 0 <= rows <= Statement.getMaxRows() is not satisfied
-
Sybase stored proc, no rows in the resultset
Hi!
I have a sybase stored proc that looks more like -
IF OBJECT_ID('dbo.ETC_DETAILS') IS NOT NULL
BEGIN
DROP PROCEDURE dbo.ETC_DETAILS
IF OBJECT_ID('dbo.ETC_DETAILS') IS NOT NULL
PRINT '<<< FAILED DROPPING PROCEDURE dbo.ETC_DETAILS >>>'
ELSE
PRINT '<<< DROPPED PROCEDURE dbo.ETC_DETAILS >>>'
END
go
CREATE PROCEDURE dbo.ETC_DETAILS
@trade_id id,
@broker_cd code,
@contact_group_id int,
@product_id id,
@security_type_id smallint
AS
if(cond1)
begin
select distinct
cd=t.cd,
name=t.name,
t.trade_id,..........
from
table1 t,
table2 tt,
table3 b,.......
where t.trade_id = tt.trade_id
and t.transaction_type_id = ttt.transaction_type_id
and .....
end
else
select distinct
cd=t.cd,
name=t.name,
t.trade_id,..........
from
table4 t,
table5 tt,
table6 b,.......
where t.trade_id = tt.trade_id
and t.transaction_type_id = ttt.transaction_type_id
and .....
end
go
GRANT EXECUTE ON dbo.ETC_DETAILS TO public
go
IF OBJECT_ID('dbo.ETC_DETAILS') IS NOT NULL
PRINT '<<< CREATED PROCEDURE dbo.ETC_DETAILS >>>'
ELSE
PRINT '<<< FAILED CREATING PROCEDURE dbo.ETC_DETAILS >>>'
go
EXEC sp_procxmode 'dbo.ETC_DETAILS','unchained'
go
GRANT EXECUTE ON dbo.dbo.ETC_DETAILS TO public
go
When run through SQL Editor - runs and returns me rows. But does not return any rows when invoked from Java. "gotResultSet" is true, but the while loop does not execute. Any clues, why? Here is the Java code.
public class AllocationExtractor {
public Collection getAllocations(int tradeId, String brokerCode, int contactGroupID, int productID, int securityTypeID) throws SQLException
Connection c = null;
String query = "{ call ETC_DETAILS(?,?,?,?,?) }";
CallableStatement stmt = null;
ResultSet rs = null;
boolean gotResults = false;
try{
c = ConnectionFactory.getSybaseConnection(url, user, pwd);
stmt = c.prepareCall(query);
stmt.setInt(1, tradeId);
stmt.setString(2, brokerCode);
stmt.setInt(3, contactGroupID);
stmt.setInt(4, productID);
stmt.setInt(5, securityTypeID);
gotResults = stmt.execute();
if(gotResults)rs = (ResultSet) stmt.getResultSet();
if (rs != null){
System.out.println("Got resultSet");
while(rs.next()){
System.out.println("Iterating the resultset");
Allocation a = new Allocation();
a.setTradeID(rs.getString("trade_id"));
System.out.println(a.getTradeID());
allocations.add(a);
public static void main(String args[]){
AllocationExtractor e=new AllocationExtractor();
Collection c = null;
int tradeID = 3115;
String broker_cd = new String("327");
int product_id = 20;
int contact_group_id = 1;
int security_type_id = 1219;
e.user = "developer";
e.url = "jdbc:sybase:Tds:devbox:12344";
e.pwd = "developer";
try{
c = e.getAllocations(tradeID, broker_cd, product_id, contact_group_id, security_type_id);
catch(SQLException se){
se.printStackTrace();Silly me! had switched the parameters to the method in Java.
-
hello
i have a servlet that connects to a db. Data is passed back in the resultset. But only for one of my columns(if i specify it in my select statement)- i want the resultset to pass back the column that the user has selected(this is via a variable called 'type')!
But i get an exception of type:
java.lang.ArrayIndexOutofBoundsException
Heres my code:
query = "select '"+type+"' from caravan_charges where..........
Resultset result = stmt.executeQuery(query);
int count = 0;
while(result.next()) {
count += result.getInt(1);
can anyone help!!!check the variable query and check the SQL statement. But the error relate to an array most probably where the code result.getInt(1);. Check my code below. by getting the column count will surely avoid the outofbounds array error.
SQLResult = StatementSQL.executeQuery(sql);
if (!SQLResult.next()) {
JOptionPane.showMessageDialog(null, "No rows retrieved.\nPlease check SQL script.");
JTable emptyTable = new JTable(dataVector, headerVector);
resultTableScroller.setViewportView(emptyTable);
else {
ResultSetMetaData mdSQL = SQLResult.getMetaData();
int colCount = mdSQL.getColumnCount();
//get column names here
for (int i = 1; i <= colCount; i++) {
String colName = mdSQL.getColumnName(i);
colName.trim();
headerVector.addElement(colName);
do {
Vector rowVector = new Vector();
for (int i = 1; i <= colCount; i++) {
String colName = mdSQL.getColumnName(i);
colName.trim();
rowVector.addElement(SQLResult.getString(colName));
dataVector.addElement(rowVector);
} while (SQLResult.next()); -
Authority experts:: Problems with storing workbooks into the role menue
Hello,
during upgrade from BW 3.5 to BW 7.0 we got the problem, that workbooks cannot be stored into the role menue.
Trace ST01 and RSECADMIN hasn't send any authority warnings.
The workbooks are stored in the role menu (PCFG). We cann't find them by searching with the
query designer.
This are the entries we made in the roles:
S_USER_AGR:
ACTVT = *,
ACT_GROUP = Menu-Role
S_USER_TCD:
TCD = RRMX
(We took notice of the new analysis authoritation )
Thanks in advance.
Greetings
Peggy Nosekgoto the particular role in PFCG and check whether you are able to see the workbook. You can see the workbook in query designer. Open BEx analyzer and use the open workbook option to search for workbooks. The search is case sensitive. If you do not see any roles assigned through BEx anayzser, run a trace in RSECADMIN with your user id.
-
In an IPI system, I have several IPs connected their interrupt output with AXI interrupt controller. In the software part, I can create several interrupt callback functions for different interrupts. I wonder Where the interrupt routine vectors stored in if I disable the AXI interrupt controller fast interrupt option? Are they stored inside the specific IP?
E.g.: if I have an VDMA and setup its callback function for general and error, then the callback function starting addresses are stored inside VDMA registers?
Thank you.>> The address of the ISR is stored in this table", so is the table stored inside the interrupt controller on inside ARM cpu? But when I used microblaze, it seems there is no interrupt controller inside the microblaze
No, that table is in a memory which implements the processor's address space. If you use MB, you can add an interrupt controller to it but that's not relevant. Interrupt controllers cause processors to jump to a fixed location in their address space. At this point in time there are two main options: either some program has registered to respond to this interrupt or not. In the latter case, the OS, bare-metal app etc takes a decision on what to do: ignore the interrupt, crash, just turn off that interrupt and return etc. If an interrupt has been registered to respond to that interrupt, the address of the interrupt service routine is in table belonging to the OS, bare-metal app etc so the code at the fixed offset jumps to the address inside that table ie it jumps to the ISR. -
Hi! I am doing a conversion from MSSQL to Oracle with C++ and MFC ODBC. Any comment is appreciated!! I have Oracle 8i and Oracle ODBC 8.1.6 installed.
My question is how to retrieve the return value AND ALSO the resultSet at the same time by using Oracle function without modifying my souce codes (except puttting mypackage. string infron of my procedure name, see below).
-- My source code in C++ with MSSQL ....
sqlStr.Format("{? = call ListOfCustomers(%i)}", nNameID);
RcOpen = CustomerList.Open(CRecordset::forwardOnly, sqlStr, CRecordset::readOnly );
Where CustoemrList is a Crecordset object...
IN DoFieldExchange(CFieldExchange* pFX) I have ...
//{{AFX_FIELD_MAP(CQOSDB_Group)
pFX->SetFieldType(CFieldExchange::outputColumn);
RFX_Long(pFX, T("Name"), mCustoemrName);
//}}AFX_FIELD_MAP
// output parameter
pFX->SetFieldType( CFieldExchange::outputParam );
RFX_Int( pFX, T("IndexCount"), mCustomerNumber);
-- m_CustomerNumber is where i store the return value!!!
-- In Oracle Version, i have similar codes with ...
sqlStr.Format("{? = call mypackage.ListOfCustomers(%i)}", nNameID);
RcOpen = CustomerList.Open(CRecordset::forwardOnly, sqlStr, CRecordset::readOnly );
-- I have oracle package/Body codes as following...
create or replace package mypackage
as
type group_rct is ref cursor;
Function listgroups(
nameID NUMBER ,
RC1 IN OUT Mypackage.group_rct ) return int;
end;
Create or replace package body mypackage
as
Function listgroups(
NameID NUMBER ,
RC1 IN OUT Mypackage.group_rct )return int
IS
BEGIN
OPEN RC1 FOR SELECT Name
from Customer
WHERE ID = NameIDEND ListGroups;
END
return 7;
END listgroups;
END MyPackage;
Ive simplified my codes a bit....
nullyes, it is exactly what i want to do and I am using Oracle ODBC driver.
I tried using procedure with 1 OUT var fo numeric value and the other IN OUT ref cursor var instead of function, but error occurs when I called it from the application. It give me a memory ecxception error!!
sqlStr.Format("{? = call ListOfCustomers(%i)}", nNameID);
RcOpen = CustomerList.Open(CRecordset::forwardOnly, sqlStr, CRecordset::readOnly );
it seems to me that the ? marker var is making all the trouble... can you please give me any more comment on this?? thanks!
null -
Updating resultsets using vectors in editable JTables
Ok i am currently retrieveing my result from a vector of vectors from a query:
public void presentResultSet (ResultSet rs)throws SQLException {
Vector dataVector=new Vector();
try
{if (!rs.next())
JOptionPane.showMessageDialog(null, " No records for student" );
else {
do{
Vector rowVector=new Vector();
rowVector.addElement(rs.getString("studentID"));
rowVector.addElement(rs.getString("moduleID"));
rowVector.addElement(rs.getString("examMark"));
dataVector.addElement (rowVector);
}while(rs.next());
} tab.setData(dataVector);
dataTableScrollPane.setViewportView(dataTable);}
catch (Exception f){ System.out.println (f.getMessage());
This method is fine actually as it displays the results onto my GUI. But problem is, i want to add another feature of the system where users can click on any cells in the JTable, edit it and JTable will be able to help me update it onto my tables in mysql.
I have set the public boolean iseditable into true.
but can anyone tell me how to write the public void setValueAt method ? how to retrieve that information that the user type into the particular cell and update it onto the database ? Please help !Ok I assume because your using a JTable that you are using your own TableModel because the DefaultTableModel usually won't do everything you want. So if your not extending DefaultTableModel you need to start there.
In your Table model you need a method called setValueAt which will overide the DefaultTableMode.setValueAt().
Your TableModel's setValueAt() will get called by the table Cell Renderer when ever a cell is edited.
So to break down setValueAt(Object aValue,int aRow,int aColumn)
Object aValue = is whatever the user has entered in the Cell. Now its an Object and not a String because you can have all sort of things in a JTable Cell such as checkboxes,buttons, etc.
The int Row and int Column are pretty self explanitory.
I don't know what your table looks like but lets say you have have 3 columns
StudentID,ModuleID,ExamMark you could do something like this
public void setValueAt(Object aValue,int aRow,int aColumn)
// In your table model there should be some Vector that contains your other
// Vectors. In this example "rows" is that Vector
// this assigns rowVector the Vector of Columns at the row
// that was edited by the user in the JTable. It should contain the 3 columns
Vector rowVector = (Vector)rows.elementAt(aRow);
// this will overwrite the current value at that column
rowVector.setElementAt(aValue,aColumn );
// you may need to cast aValue into whatever Object you plan on storing probably a string
// ie. rowVector.setElementAt((String)aValue,aColumn );
} Your Table Model should now contain the new value in its rows Vector all you have do is add someway to save that new Vector back into the Database.
Hope this helps I didn't compile it but I think it will work or at least give you a better understanding....
Or maybe I confused you more.
Good Luck
Justin -
I need to add the values stored in the session object into the html textbox
Dear Sir,
i have been trying to create an edit employee details page
What i have done till now is as follow:
1. Got employee id from HTML page.
2. Compared it with the id stored in the database.
3. If the id is correct then pulled the record of the corresponding employee and stored it in the session object.
4. Dispatched the session values to another servlet EditEmpDetails2.java
what i need to do now
5. Now i need to set the session values in the text field of the html form
6. I also need to be able to edit those vales and store the edited values in the database.
Please help me as i have tried doing it for 1 week without any clues
i have tried to create a html page which is something like this:
<html>
<head>
<title>Edit Employee Details Page</title>
<body BGCOLOR="red" text="black">
<h1 ><font color="black">Edit Employee Details Page</font></h1>
<form action = "EditEmpDetails" method="Get">
<table width="50% align="center"
<tr><td>Employee ID: </td>
<td><INPUT TYPE="TEXT" name="employeeid"<br></td></tr>
<tr><td><center><input type="submit" value="submit"></center></td></tr>
<tr><td><center><input type="reset" value="reset" ></center></td></tr>
</table>
</form>
</body>
</html>
design of my servlet EditEmpDetails.java
public void EditEmpDetails1 extends HttpServlet
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
PrintWriter out = response.getWriter();
response.setContentType("text/html");
HttpSession session = request.getSession();
String employeeid;
String X = request.getParameter("employeeid");
System.out.println("Employee iD:" + X);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:murphy");
String query = "Select * from users where employeeid=?";
PreparedStatement stat = con.prepareStatement(query);
System.out.println(stat);
stat.setString(1,X);
ResultSet rs = stat.executeQuery();
while(rs.next())
String Z = rs.getString(password);
if(Z.equals(X))
String A = rs.getString(1);
session.setAttribute("employeeid", A);
String B = rs.getString(2);
session.setAttribute("firstname", B);
String C = rs.getString(3);
session.setAttribute("lastname", C);
String D = rs.getString(4);
session.setAttribute("gender", D);
String E = rs.getString(5);
session.setAttribute("dateofbirth", E);
String F = rs.getString(6);
session.setAttribute("address", F);
String G = rs.getString(7);
session.setAttribute("postalcode", G);
String H = rs.getString(8);
session.setAttribute("phone", H);
String I = rs.getString(9);
session.setAttribute("mobile", I);
String J = rs.getString(10);
String url = "/EditEmpDetao;s.java";
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url)
dispatcher.forward(request,response);
catch (Exception e)
system.out.println(e)
I do not know how to put the values stored in the session object into the html text box3. If the id is correct then pulled the record of the corresponding employee and stored it in the session object.do you really need to store this in session object?
5. Now i need to set the session values in the text field of the html form which form? in a new html/jsp page? i suggest go for a JSP
In your JSP page use JSP expression tags to put the session attributes.
it's something like : <input type='text' name='employeeid' value='<%= session.getAttribute("employeeid") %>' >and you need to generateanother servlet for saving the details/modifications to the database.
I think i m clear enough.
if you need more clarifications. just try it and then post your problem.
Diablo -
Problems calling stored procedure with out ref cursors
Hi,
I am calling an oracle stored procedure and having problems. This is the code:
ResultSet cursor1, cursor2, cursor3, cursor4,cursor5,cursor6;
String sql = "BEGIN SYSADM.PKG_SERVICE.SERV_MAIN(:1,:2,:3,:4,:5,:6,:7,:8,:9) \n; END;";
CallableStatement call = null;
try
call = conn.prepareCall(sql);
call.setString(1,blah1);
call.setString(2,blah2);
call.setString(3,blah3);
call.registerOutParameter(4,OracleTypes.CURSOR);
call.registerOutParameter(5,OracleTypes.CURSOR);
call.registerOutParameter(6,OracleTypes.CURSOR);
call.registerOutParameter(7,OracleTypes.CURSOR);
call.registerOutParameter(8,OracleTypes.CURSOR);
call.registerOutParameter(9,OracleTypes.CURSOR);
call.execute();
cursor1 = ((OracleCallableStatement) call).getCursor(4);
cursor2 = ((OracleCallableStatement) call).getCursor(5);
cursor3 = ((OracleCallableStatement) call).getCursor(6);
cursor4 = ((OracleCallableStatement) call).getCursor(7);
cursor5 = ((OracleCallableStatement) call).getCursor(8);
cursor6 = ((OracleCallableStatement) call).getCursor(9);
on the cursor1 = line I get this exception:
06/08/08 15:07:01 java.lang.ClassCastException: com.evermind.sql.FilterCallableStatement
this is a web service running in JDeveloper 10.1.2
DennisDennis,
There is only one "data-sources.xml" file in my JDeveloper 10.1.3. It is in the "\j2ee\home\config" subdirectory.
But the again, I have not used my JDeveloper to create any Web services.
I really think you should try the JDeveloper and ADF forum.
Also, there are several debug properties you can set for OC4J.
Since you say you are using 10.1.2, the following Web page may be helpful:
http://www.oracle.com/technology/tech/java/oc4j/htdocs/oc4j-logging-debugging-technote.html
Good Luck,
Avi. -
Problem with collecting several classes in a Vector.
Hi,
sorry if I'm asking about a thing which was discussed earlier, but with the search tool I found nothing :-((
I have a following problem: I got some data from the DB. First, it will be packed in a class (say, it's called myClass) which has set-methods for that. Then this class is packed into a vector and the same thing repeats as long as the ResultSet has more data. It looks like this:
ResultSet rs = myPreparedStatement.executeQuery();
while(rs.next()){
myClass = new MyClass();
myClass.setVar1(rs.getInt("Column1"));
myClass.setVar1(rs.getString("Column2"));
myClass.setVarX(rs.getInt("ColumnX"));
vector.add(myClass);
myClass = null;
The problem is that after all I have a vector full with the elements, which all have the values of the last data-set.
What am I doing wrong? Please help.
Many thanks in advance
Emilvariable in the myClass are static?Ooh. Good call. I didn't think of that.
No, they are not static, otherwise I wouldn't lose my time writting get- and set-methods.
Thank you, jverd, for the advise about "code"-tag and sorry... I didn't believe my eyes as I see the behavior I described, but the program do behave like this :-( That's why I've written, that it must be something very stupid.
2) myClass = null is pointless and does nothing useful there. I have noticed it already and this line is deleted.
public Properties getDataList(Properties props){
MyClass myClass = (MyClass)props.get("myclass");
/*Here I fill my PreparedStatement with the data from myClass
and execute it */
ResultSet rs = myPreparedStatement.execute();
while(rs.next()){
myClass = new MyClass();
myClass.setVar1(rs.getInt("Column1"));
myClass.setVar1(rs.getString("Column2"));
myClass.setVarX(rs.getInt("ColumnX"));
vector.add(myClass);
props.put("vector", vector);
return props;
}And as I've said - while debugging I could see all the values the ResultSet deliveres (and they are not the same) and all elements of the vector being overwritten with those new values. -
Best efficiently way to transform a large rows ResultSet to Vector
Best efficiently way to transform a large rows ResultSet to a 2-dimensional ArrayList or Vector in a minute ?
If you can help me solve this problem , I 'll give you my duke .Why don't you use info objects? For example your table is having col1(number),col2(text/varchar),col3(text/varchar), create an info object like this,
class MytableInfo implements java.io.Serializable {
private int col1;
private String col2;
private String col3;
public MytableInfo(int col1,String col2,String col3) {
this.col1=col1;
this.col2=col2;
this.col3=col3;
public int getCol1() {
return col1;
//Getter for other two properties too.
and in your ResultSet class,
Vector v = new Vector();
while(rs.next()) v.add(new MytableInfo(rs.getInt(1),rs.getString(2),rs.getString(3));
return v;
So, it will be easier for retrieving the values later and it is a clean way of doing it.
Sudha
Maybe you are looking for
-
Elementary: what is the dollar-sign ($) in a column name mean?
I periodically see dollar signs in column names in Oracle tables. For example, when I create a LOB, often times the LOB segment will end in a dollar-sign (or two). Sometimes when one of the developers creates an object, I see some of the field namess
-
Hi there, I have JPanel which contains label and image icon and i want to drag them out to another panel and droped there. Is this really doable with swing. Please share your thoughts with me Thanks, - Prashant
-
Can't make a Genius Bar appointment
I went in to my local Apple store today because my Mac crashed and the message was due to no memory. When they checked it, they said it had to be seen by a Genius Bar tech and to go home and make an online appt. I have done this many times so imagine
-
I need to know how to make a game !!!!!
I am 12 years old and i need to know how to make a game... i'm very good with computers and i just need to know how to make a game.. like runescape.
-
When I go into the Organizer and select "People" and then select a specific person to view the pictures I have of them, it doesn't display all the pictures, but displayes some as an Icon of some type. Why can't I see all the pictures?