Win a copy of Head First Android this week in the Android forum!

Amit Da

Greenhorn
+ Follow
since Mar 07, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Amit Da

I have my application running at say http://myapp1.com/APP1
On a button click it opens a window doing window.open and passes URL of our own web application, which is hosted at http://myapp2.com/APP2
Now when user performs some action in the 2nd app and clicks a button we want to call a javascript function from first app and perform some action such as refresh of page in parent window (thats in app1). This all works fine as long as the page l opens window with a page in same application app1. But the cross domain stuff doesn't work due to browser security. How can I make this happen??? Has anyone come across such a case? What I can't, and don't want to do is - app2's button click updating a database table row and the parent window-keeps polling the table row to see if it got updated, to know if the child window is closed...Parent window needs to know if child window was closed due to OK click or Cancel click....how do I achieve this? any clues...?
To clarify myself,
1. error case is no problem. In there the error xml comes back and using normal AJAX cycle I can change the same page showing error message. Issue is with Valid case because after checking in servlet A, control goes to servlet B and that is where the response is generated
I just need to know a way to get that response html in callback javascript and change the current window.document

2. window.location is an inherent GET htmmp method call to an active/passive resource. I must POST the contents (because I want to send all params as part of body of http message and NOT header (in short, over URL)) so this approach doesn't seem workable. Does document.location work similar to window.location?

Thanks anyway for responses
[ August 08, 2007: Message edited by: Amit Da ]
Two doubts:
1. I am on server side (in servlet, ofcourse) and able to determine if to give user an "Invalid" message or if valid using request dispatcher forward to the next page that is rendered using servlet B. Why would I need to do the extra roundtrip to first return a result to browser JavaScript method that would then send another request to servlet B?
This means pushing business logic from serverside to client, which I don't prefer. Are you saying I cannot do what I wish to do?
I have seen AJAX application that runs in just one page fully. I am sure they would be getting pieces of data and just changing page contents. I wonder if they are creating entire html page and replacing document or always just create divs and manipulate the inner divs inside a template page.

2. If I do what you suggest I should do there will be multiple such request every time I click on any navigation button, whose response will come back to browser and then send another request to servlet for rendering pages. Looks like a lot of overhead.
Let's assume for a moment I still would do it. How would I redirect to another active resource from the callback javascript?
please just delete it instead. I couldnt.
it's already posted there a post before
I have a servlet A that I would call on a button click using AJAX. It checks certain things posted and if invalid comes back with error xml, which gets displayed on the same page.
In Valid case, I want to forward request and response objects to another servlet B, that would gather data from database and render the page using the response object.
This case is not working well for me. Here the callback JS function would not have anything to do in the page.
request.responseXML is null but request.responseText has the entire html document. I am wondering how in the callback JS I could take this document and replace the one in current window.document
Please help...any ideas about how to get this?
I would really dislike to have a response xml from servlet A in callback JS, that we would need to check and make another client to server (to servlet B) call to show second page...
any ideas???
thanks in advance,
I have a servlet A that I would call on a button click using AJAX. It checks certain things posted and if invalid comes back with error xml, which gets displayed on the same page.
In Valid case, I want to forward request and response objects to another servlet B, that would gather data from database and render the page using the response object.
This case is not working well for me. Here the callback JS function would not have anything to do in the page.
request.responseXML is null but request.responseText has the entire html document. I am wondering how in the callback JS I could take this document and replace the one in current window.document
Please help. Any ideas about how to get this?
I would really dislike to have a response xml from servlet A in callback JS, that we would need to check and make another client to server (to servlet B) call to show second page.
Any ideas?
Thanks in advance,
[ August 08, 2007: Message edited by: Amit Da ]
I found the issue. The code was just not going in right block that would kick off threads but would go in the serialized block.(as I have support for both modes).
With that fixed the processes do INDEED run in parallel, kicked off from threads..wonderful
In my application I kick off a batch file that runs osql commands and executes scripts for our dbas. There are some scripts that I can run in parallel and so I am now creating threads to run those. However I still see a serialized execution of threads one after another.

Is this even possible to kick off processes (using Runtime.exec) in a thread run() method and expect it to run concurrently??
Would my running process be blocking the parent process and so the sibling threads for running at all??

How can I achieve what I am looking for..

please help
Does current version of JSF have built-in support for Java 5?
Have anyone used java 5 with it? any issues faced?
16 years ago
JSF
From a preparedStatement one can easily know the jdbc type of any parameter.(refer to jdk1.4 javadoc of PreparedStatement). prepStmt.getParameterMetaData returns ParameterMetaData which has getParameterType(int param) giving jdbc type. Now pstmt.setNull(idx, jdbcType) can be called with ease
Actually getTables() method of DatabaseMetaData gives info about a table or tables matching pattern specified. But in this case since the user needs information about columns getColumns() method is more suitable.
I am using Oracle's connection pool for managing connections. After using a ResultSet or executing a DML statement, I close the ResultSet, Statement and also finally the connection object(logical connection obtained from pool) to free the resources.
But it was noticed that in database there were several INACTIVE CURSORs and at some point they even reached the MAX number set in init file. Does anyone know how to resolve this ?
I tried settings -
setCacheInactivityTimeout(1),
setCacheTimeToLiveTimeout(1);
setThreadWakeUpInterval(60)
on the connection cache object and that gets rid of the CURSORs faster but I am not sure what would be the reasonable values. The first two methods take a long. Is that in milis/s/minutes/hours ??? what's the unit ? Is anyone using these methods and knows what would be good settings for an enterprise app pool that has a lot of database interaction and several users(50+) hitting database at same time ?
Code snippet of pool usage:
OracleConnectionPoolDataSource ocpds = new OracleConnectionPoolDataSource(); ocpds.setDriverType("thin");
ocpds.setPortNumber(1521);
ocpds.setDatabaseName(lsDatabaseName);
ocpds.setServerName(lsServerName);
ocpds.setUser(lsUser);
ocpds.setPassword(lsPassword);
OracleConnectionCacheImpl ocach = new OracleConnectionCacheImpl(ocpds);
/*
ocache.setCacheInactivityTimeout(1);
ocache.setCacheTimeToLiveTimeout(1);
ocache.setThreadWakeUpInterval(60);
*/
-Amit
Actually the ideal interface to be used here is DatabaseMetaData. You can get an object of its type from connection object.
Call method getColumns() on it. You need to pass following values
1.catalog - for Oracle pass null - because Oracle tables are not within a catalog - its a concept like package - for getting parameters of a stored proc, you'd have to pass package name here as you can have stored proc in a package.
2.schema = username value that owns table
3.tableName = exact table name or a pattern like MYTAB% (all tables starting with MYTAB)
4.columnName = if you need only certain columns matching a pattern pas pattern - e.g. COL% - all columns whose names start with COL
if you want all columns pass null or %
This getColumns() method does same thing as your "select COLUMN_NAME, DATA_LENGTH, DATA_TYPE from user_tab_columns" query (internally driver might be calling same). In short this class and its methods like getColumns() are very useful and you should use them as much as you can...
http://java.sun.com/j2se/1.3/docs/api/java/sql/DatabaseMetaData.html
Amit
I am trying to get a ResultSet object by executing a stored procedure in Oracle.
The ResultSet is one of the parameters of this procedure. Typical code:
CallableStatement st = cn.prepareCall("{ call sc_getkeyfieldinfo(?,?) }");
st.setMaxRows(2); //this doesnt do anything
st.setString(1, "T11_2003_1");
st.registerOutParameter(2, OracleTypes.CURSOR);
st.execute();
ResultSet rs = (ResultSet) st.getObject(2);
while (rs.next()) {
System.out.println(rs.getString(1));
}
How would I get only certain number of rows in my ResultSet ? The setMaxRows on a callable statement did not do anything. Neither does the setFetchSize().
When we get a ResultSet directly by executing a query from a Statement, these maxSize and fetchSize parameters set there do the job and return a ResultSet of specified size(# of rows). But on a CallableStatement it didn't do anything.
Anyone knows how to achieve this ???
Amit
[ September 18, 2003: Message edited by: dalAm ]
since when did oracle start supporting a return value alongwith an insert statement like the way Simon you've mentioned?
begin insert into foo(bar_key, bar) values (bar_seq.nextval,?) return bar_key into ?; end
Would this work only in context of callable statement(thus making work like a pl*sql block ? as in procedure) or work even in a simple statement while executing it with st.execute(sql) ?
I don't think this is still in the standard SQL, right?
Anyway, that's cool! In sql server we can use something similar. Using "select @@identity" returns the value of identity generated after executing an insert statement if the table has an identity column.