This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!

Sebastiano Barbieri

Greenhorn
+ Follow
since Jul 21, 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 Sebastiano Barbieri

Ok people. I'm using db2 and if I try to execute the statement:
Update t set i = 10 where i = 123
this row where i = 123 doesn't exist and I get the following warning: SQL0100W No row was found for FETCH, UPDATE or DELETE; or the result of a
query is an empty table. SQLSTATE=02000
So far...everything's fine. Now I try to catch this warning through jdbc. Here's my code:
import java.io.*;
import java.util.*;
import java.sql.*;
class PELoad {
static {
try {
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
} catch (Exception e) {
System.out.println(e);
} //catch
} //static
public static void main(String args[]) {
try {
Connection con = DriverManager.getConnection("jdbc b2 ELoad");
Statement stmt = con.createStatement();
stmt.executeUpdate("Update t set i = 10 where i = 123");
SQLWarning warning = stmt.getWarnings();
if (warning != null) {
System.out.println("\n---Warning---\n");
while (warning != null) {
System.out.println("Message: " + warning.getMessage());
System.out.println("SQLState: " + warning.getSQLState());
System.out.print("Vendor error code: ");
System.out.println(warning.getErrorCode());
System.out.println("");
warning = warning.getNextWarning();
} //while
} //main
con.close();
} catch(Exception e) {System.out.println(e);}
} //main
} //PEload
compiles fine...java program...computer starts thinking...sbam! nothing happens, not even a little error message. Any idea what I'm doing wrong?
Thanx a lot to all of you guys, you were a great help and gave me a lot of ideas about the topic. I used the reseeding option since truly every thread might generate multiple values. Works great! Thanx!
[ July 24, 2003: Message edited by: Sebastiano Barbieri ]
My program starts n threads at the same time and at a certain point of the code a random number is generated. Correct me if I'm wrong if the system time in milliseconds is the same this causes the generated number to be the same for each thread. The problem I'm facing is that I'd like each thread to generate a different number, which doesn't happen if I'm starting them at exactly the same time. I was thinking about a time delay before starting the threads, but I don't like the idea too much. Any suggestions? Thanx in advance.
oh man! all right, I'm quite new to java and when I had a blank line (carriage return) in the file I was reading I got a null pointer exception. My first thought was that the while loop breaked when it found an empty line. Now I see I was wrong and that the error was probably that I tokenize the lines coming in and the program is trying to tokenize an empty string, which is probably why I get the exception? Anyway with an if statement at the beginning the problem is solved. Thanx a lot to both of you.
Ps hehe guess I couldn't find a lot cause my question was stupid
18 years ago
ok, I did some research on the topic not beleaving I couldn't find anything, but maybe it's just an unlucky day. What I'm trying to do is simply to get my program to skip blank lines when reading from a text file. For now I'm using something like:
BufferedReader in = new BufferedReader(new FileReader(filename));
String line;
while ((line = in.readLine()) != null) { //do something}
Any suggestions?
Thanx in advance.
18 years ago