Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!

karim qazi

Greenhorn
+ Follow
since Mar 22, 2001
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 karim qazi

I am have an RMI Swing app using JWS that is performing callbacks on the client.
I have read that when using JWS with an RMI swing app that the events that the server sends to the client via RMI are handled within a different thread queue than the GUI event queue.
So to handle this situation I have tried using SwingUtilities.invokeLater(). The Runnablel class that I am passing into the invokeLater() has code within it that talks to the Server via RMI and by having this code in the run() of the runnable class it is generating ClassCastExceptions.
I have placed printlns in the code to see if the class isnt of the type I am casting to but this is not the case.
I have a ServiceFactory.getAdminService() which casts to AdminService. I can see by using :
Remote remoteObj = Naming.lookup(lookupURL);
System.out.println("remoteObj type: " + remoteObj.getClass());
That the remote object being returned is of type AdminServiceImpl_Stub which is the RMI stub (this is how it has always worked). But for some reason I am getting a class cast exception.
Any suggestions are greatly appreciated!
Thanks!
16 years ago
you can try something like this...
Statement statement = connection.createStatement();
//whatever you are looping through
while(true){
String sqlString = "Insert into table (name)values
('" + name + "')";
statement.addBatch(sqlString);
}
statement.executeBatch();
I am using MS SQL Server 2000 and Tomcat 4.0.
I am using Microsoft's JDBC Driver for MS SQL Server 2000.
I have set up a data source in Tomcat and it works fine.
I was reading throught the documentation on the driver I am using and was wondering if I had to execute code like this to take advantage of connection pooling :
Context initialContext = new InitialContext();
Context envCtx = (Context) initialContext.lookup("java:comp/env");
ConnectionPoolDataSource pooledDataSource = (ConnectionPoolDataSource) envCtx.lookup("jdbc/SQLSERVER");
PooledConnection pcon = pooledDataSource.getPooledConnection();
Connection con = pcon.getConnection();
or if I could execute code like this :
Context initialContext = new InitialContext();
Context envCtx = (Context) initialContext.lookup("java:comp/env");
DataSource dataSource = (DataSource) envCtx.lookup("jdbc/SQLSERVER");
Connection con = dataSource.getConnection();
Would the code above that doesnt use the ConnectionPoolDataSource interface still be taking advantage of ConnectionPooling?
Is this true or do you have to cast the jndi lookup of your data source to a ConnectionPoolDataSource to take advantage of connection pooling??
Do all jdbc compliant drivers take care of implementing the ConnectionPoolDataSource for you so all you have to do is define a datasource and it will pool the connections automatically??
Thanks.
Karim

[This message has been edited by karim qazi (edited November 20, 2001).]
I have created a p3p policy for our website.
I have validated it against the W3C's policy validator and it checks out fine.
I have defined a compact policy in the header of a webpage so that if IE 6.0 is set to "high" it will still allow cookies to be set.
I have to add the compact-policy to the header via a META TAG:
(< META HTTP-EQUIV='P3P' CONTENT='policyref="http://test.pacsun.com/w3c/p3p.xml"; , CP="NON CUR OUR DEM BUS"' >)
because our HTTP Server does not allow the config of HTTP HEADERS from an admin standpoint.
The meta tag above does not seem to register with IE 6.0 but it validates my P3P policy fine when running against the W3C validator.
Can anyone please help me!!!
Thanks.
I edited this to allow his Meta tag to show---Carl
[This message has been edited by Carl Trusiak (edited November 08, 2001).]
I have created a p3p policy for our website.
I have validated it against the W3C's policy validator and it checks out fine.
I have defined a compact policy in the header of a webpage so that if IE 6.0 is set to "high" it will still allow cookies to be set.
I have to add the compact-policy to the header via a META TAG:
(< META HTTP-EQUIV='P3P' CONTENT='policyref="http://test.pacsun.com/w3c/p3p.xml"; , CP="NON CUR OUR DEM BUS"' >)
because our HTTP Server does not allow the config of HTTP HEADERS from an admin standpoint.
The meta tag above does not seem to register with IE 6.0 but it validates my P3P policy fine when running against the W3C validator.
Can anyone please help me!!!
Thanks.
I edited this to allow his Meta tag to show---Carl
[This message has been edited by Carl Trusiak (edited November 08, 2001).]
18 years ago
how do you specifify to use jit compiler when running a class?
also can anyone explain how the jit complier works?
thanks.
18 years ago
Can anyone explain to me how to use the ConnectionPoolDataSource vs. DataSource.
I know how to get a connection using the DataSource interface how can you get a ConnectionPoolDataSource instead?
How can I delete a cookie in java.
I tried the following code but it does not seem to work:
public static void deleteCookie(HttpServletRequest request, String cookieName) {
Cookie currentCookie;
Cookie[] cookieList = request.getCookies(); //get cookies
if (cookieList != null) {
for (int i = 0; i < cookieList.length; i++) {
currentCookie = cookieList[i];
if (currentCookie.getName().equals(cookieName)) {
currentCookie.setMaxAge(-1);
break;
}
}
}
}
I thought setting its maxage to -1 would automatically expire it.
Any help is appreciated.
18 years ago
so seralize the object into a database record?
if i am doing this why wouldnt i just store the data the bean holds into the database instead of storing the object?
i guess my real question is when is most applicapble to use seralizable?
18 years ago
So if i were to serialize a javabean lets say a User javabean that holds the users name,password, etc.
Would it be better to seralize the beans data or hold the beans information inside of a session when using jsp?
Also when you seralize multiple beans into the same file how does the file input stream know which object you want to read in?
18 years ago
this was very helpful to me.
thank you very much.
so when writing a javabean for instance that you want other objects to be able to seralize meaning write to an output stream you must implement serializable?
18 years ago
so if you implememnt serializable you can write the object to a file and then read it back in to see what values it was holding?
18 years ago
i can implement java.io.serializable and i cannot see any diffrence when my class is executed.
i know you are supposed to implement this interface when you want to retain information a object might have but to retain the information you must write the data to an output stream and this can be done without ever implementing this serializable interface.
can anybody show an example of diffent outcomes of when a class executes when implementing the serializable interface and when not implementing it???
any help is greatly appreciated.

------------------
18 years ago
would the code below be a correct implementation of using static variables,constructors, and methods?
public class CreateDateTime{
private static GregorianCalendar todaydate;

static{
todaydate = new GregorianCalendar();
}

public static String UniqueRandomNum(){
//Create UniqueRandomNum
return createDate() + createTime();
}

public static String createDate(){
String year =Integer.toString(todaydate.get(Calendar.YEAR));
String month = Integer.toString(todaydate.get(Calendar.MONTH) + 1);
String day = Integer.toString(todaydate.get(Calendar.DATE));

//check if month has length of 1 and attach 0
if (month.length() == 1){
month = "0" + month;
}

//check if day has length of 1 and attach 0
if (day.length() == 1){
day = "0" + day;
}
return year + month + day;
}

public static String createTime(){
//Create current time
String hr = Integer.toString(todaydate.get(Calendar.HOUR_OF_DAY));
String min = Integer.toString(todaydate.get(Calendar.MINUTE));
String sec = Integer.toString(todaydate.get(Calendar.SECOND));
String milsec = Integer.toString(todaydate.get(Calendar.MILLISECOND));

if(min.length() < 2) min = "0" + min;
if(sec.length() < 2) sec = "0" + sec;
if(milsec.length() < 3) milsec = milsec + "0";

return hr + min + sec + milsec;
}
}
18 years ago
Yes that helps.
So when should I use a static constructor?
For instance if you want to initalize ceartin static variables without instantiating a object.
Also when to use static variables?
Thanks.
18 years ago