Java Reference
In-Depth Information
LISTING 20.5
Continued
28: String data = “jdbc:mysql://localhost/cool”;
29: try {
30: Class.forName(“com.mysql.jdbc.Driver”);
31: conn = DriverManager.getConnection(
32: data, “username”, “password”);
33: } catch (SQLException s) {
34: System.out.println(“SQL Error: “ + s.toString() + “ “
35: + s.getErrorCode() + “ “ + s.getSQLState());
36: } catch (Exception e) {
37: System.out.println(“Error: “ + e.toString()
38: + e.getMessage());
39: }
40: return conn;
41: }
42: }
Lines 28-32 of the DmozHandler application should be changed to reflect your own data-
base drive, username, and password. You also might need to change the rest of the string
used to connect to the database, depending on your driver.
The server is run by specifying the port number at a command line, as in this example:
java DmozServer 4413
After the server is up and running, you can modify the SiteClient application to con-
nect to a different XML-RPC server. Change lines 36-37 of Listing 20.3 to replace
localhost:4413 with a reference to the server's computer followed by a colon and port
number, as in the following:
XmlRpcClient client = new XmlRpcClient(
“http://cadenhead.org:4413/”);
Running this particular XML-RPC server also requires a database.
To download a Microsoft Access database containing information
on 1,000 websites from the Open Directory Project, visit this
book's website at http://www.java21days.com and open the Day
20 page. The database is in a file named dmozdata.mdb .
NOTE
 
Search WWH ::




Custom Search