Julio Lopez

Greenhorn
+ Follow
since Nov 14, 2000
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 Julio Lopez

I don't have much experience with the net driver. If I was you I would try out the app driver. To use the app driver you will need to install DB/2 CAE or DB/2 run time client on your Win 2K machine. After installation go to X:/SQLLIB/java12 (where X is the drive where the DB/2 run time client is installed) and run "usejdbc2". Then go to My Computer right click and choose Properties. Click the Advanced tab and choose Environment Variables. Make sure that X:/SQLLIB/java/db2java.zip is in the classpath. Do a reboot and the services should start automatically. Open the Control Center, right click on Systems and choose add. Under host name enter in the IP address of the DB/2 server and click retrieve. The server information should be retrieved and filled into the text boxes, then click OK. In the Instance folder right click and choose add. Click refresh and then click OK. Highlight the Databases tag, right click and choose add. Click refresh and choose the database you want to query. Now go back to your java code and instead of "COM.ibm.db2.jdbc.app.DB2Driver" in the Class.forName statement use "COM.ibm.db2.jdbc.app.DB2Driver" And the URL should be jdbc:db2:XDATABASE (where XDATABASE is the nickname of the database that you selected in the client (if not specified the nickname is the same as the name) ) Give that a try and let me know. If this gives you the same error there must be some sort of service not running properly on the server.
Julio Lopez
M-Group Systems
Usually when I get this error it is because I am using a prepared statement and the number of parameters I set using prepStatement.setXXX does not correspond with the "?" in the SQL statement. It does not appear you are using a prepared statement but just wanted to tell you this is when I get it. Also, according to your code sample the SQL statement you are trying to execute in:
rs = us.executeQuery(SELECT_CATEGORIES);
is not the same as the SQL statement at the bottom
here is the string def --
SELECT_SUBCATEGORIES = "(SELECT DISTINCT cat FROM products)";
Julio Lopez
M-Group Systems
I do a lot of DB/2 JDBC work on a Win 2K box. Tell me what sort of errors are you getting? Your code looks OK. Also, have you tried using the COM.ibm.db2.jdbc.app.DB2Driver instead? Let me know and I will see if I can help you out.
Julio Lopez
M-Group Systems
> Can anybody help me with how where should I put the bean class, paths etc.
It seems that you have put everything in the right place. JSP's in the web directory, Servlets and JavaBeans in the servlets directory.
Just some thoughts,
Is SpellCheck inside a package, if it is you will need to state this in the useBean tag.
<jsp:useBean id="spellCheck" type="packageA.SpellCheck" scope="request">

</jsp:useBean>

Make sure that the servlet directory is in the classpath for your web application.
i.e.
c:\WebSphere\AppServer\hosts\default_host\webapp\servlets
I really can't diagnose the problem without more detail.
Julio Lopez
M-Group Systems
17 years ago
I don't know of any elegant way to do this what I would do is,
1. parse the date String into its constituent parts
2. create ints from the parts
3. create an instance of java.util.Calendar
4. set the Calendar time with the ints
5. get the long value of the date and use that when you create the instance of the java.util.Date
try {
int theYear = java.lang.Integer.parseInt(dateStr.substring(0,4));
int theMonth = (java.lang.Integer.parseInt(dateStr.substring(4,6))) - 1; // subtract one month because month 0 is January
int theDay = java.lang.Integer.parseInt(dateStr.substring(6,8));
java.util.Calendar theCalendar = java.util.Calendar.getInstance();
theCalendar.set(theYear, theMonth, theDay);
java.util.Date theDate = theCalendar.getTime();
}
You could avoid using the java.util.Calendar class and just calculate the long value of the date when you get the int values of the year, month and day.
Julio Lopez
M-Group Systems
[This message has been edited by Julio Lopez (edited July 13, 2001).]
17 years ago
A few things, in the "/home/db2inst1/sqllib/java12" directory is there a file called "inuse"? Also, make sure that the db2java.zip file is in the directory, when you run "usejdbc2" some files including db2java.zip get decompressed from a file and then are transferred to the (most probably, I am a Windows user) "/home/db2inst1/sqllib/java" directory. So while I am confident you know what you are doing, make sure that db2java.zip is still in that directory. If it is not, Uninstall the DB/2 driver instance in the administrative console and Install it pointing to the db2java.zip file in the "/home/db2inst1/sqllib/java" directory. Check this stuff out and let me know.
Julio Lopez
M-Group Systems

I am guessing you are getting this error on compilation. If you want to avoid this explicitly state what sort of Object each variable is. For example,
java.sql.Date aDate = ...
java.util.Date anotherDate = ...
instead of
Date aDate = ...
Date anotherDate = ...
Hope this helps,
Julio Lopez
If you go to your WebSphere Administration Console, expand out the machine name, expand out the server you are dealing with and highlight the servlet engine of that server there is an option to change to Servlet 2.2/JSP 1.1 Full Compliance Mode. If you do this your problem should be solved.
Julio Lopez
M-Group Systems
17 years ago
Instead of using "NIRANJAN" in the URL I would try using the IP address instead.
String conn = "jdbc:db2://NIRANJAN:3456/SAMPLE";
Julio Lopez
M-Group Systems
Looks like I am the java.math.BigDecimal advocate of the day. Try this,
try {
java.math.BigDecimal unitPriceBigDecimal = new java.math.BigDecimal(req.getParameter("unitprice"));
java.math.BigDecimal quantityBigDecimal = new java.math.BigDecimal(req.getParameter("qty"));
java.math.BigDecimal totalBigDecimal = unitPriceBigDecimal.multiply(quantityBigDecimal);
totalBigDecimal = totalBigDecimal.setScale(2, java.math.BigDecimal.ROUND_HALF_UP);
}
catch (NumberFormatException e) {
}
catch (Exception e) {
}
Julio Lopez
M-Group Systems
17 years ago
Or you could use the java.math.BigDecimal class,
java.math.BigDecimal aBigDecimal = new java.math.BigDecimal(10.35009);
java.math.BigDecimal anotherBigDecimal = new java.math.BigDecimal(11.4765);
aBigDecimal = aBigDecimal.setScale(2, java.math.BigDecimal.ROUND_HALF_UP);
anotherBigDecimal = anotherBigDecimal.setScale(2, java.math.BigDecimal.ROUND_HALF_UP);

Julio Lopez
M-Group Systems

17 years ago
I think there is a setup file that installs DB/2 and it is during the installation that the .cab gets decompressed.
Julio Lopez
M-Group Systems
Just write the javascript array out using a loop. Assuming vector is referenced by v,
<%
int count = 0;
%>
var theArray = new Array(<%= v.size() %> )
<%
for (Enumeration e = v.elements() ; e.hasMoreElements() {
%>
theArray[<%= count %>] = "<%= e.nextElement() %>"
<%
count++;
}
%>
This should work.
Julio Lopez
M-Group Systems
17 years ago
This sounds like a javascript problem. Is your validateMe function returning a boolean? If it does not return true the form will not submit.
I have a form that calls a validation page (ShowValues.jsp) but when i press the submit button, nothing happen. What's wrong???
Julio Lopez
M-Group Systems
[This message has been edited by Julio Lopez (edited June 29, 2001).]
17 years ago
Try this,
java.lang.String currentValue;
java.lang.String[] parameterValues;
parameterValues = request.getParameterValues(parameterName);
Then to extract the values,
for (int i=0; i < parameterValues.length; i++) {
currentValue = parameterValues[i];
..do whatever
}
Hope this help,
Julio Lopez
M-Group Systems
17 years ago