Hello World 73 The is a little more complex because it consists of up to three different components. The general format of the is //[:
][/] Notice the use of the double slashes just as with an HTTP URL. The component is the domain name or IP address of the server hosting the MySQL database application. The can be followed by a colon and a port number where the database application accepts connections. The default port in MySQL is 3306; the Connector/J driver will also default to port 3306 if one is not found in the . Finally, the database the driver should begin using when a connection is first made can be added to the . Here are a few examples: jdbc:mysql://localhost jdbc:mysql://localhost/accounts jdbc:mysql://192.156.44.3/db_dev jdbc:mysql://database.company.com/prod jdbc:mysql://database.company.com:4533/prod In each of the sample URLs, the JDBC driver will be able to determine which host currently is running a MySQL database application, what port to communicate through to the database system, and the initial database. In addition to specifying the initial database that the application should use for the current connection, the Connector/J driver allows properties to be appended to the driver string. For example, we can specify the username and password to be used with the connection: jdbc:mysql://192.156.44.3/db_dev?user=newuser&password=newpassword The properties are appended to the driver string using the ? and & delimiters. The first property must use the ? delimiter, and all others must use &. Connector/J includes quite a few properties that can be specified on the connection string, as shown in Table 5.1. Table 5.1 Connection Properties NAME DESCRIPTION DEFAULT user The username for the connection. None password The password for the user. None autoReconnect Set to true if the connection should automatically be reconnected. false maxReconnects If autoReconnect=true, represents the 3 total reconnect attempts. initialTimeout If autoReconnect=true, represents 2 the time to wait (in seconds) between reconnect attempts.
Hint: If you are looking for good and high quality web space to host and run your java application check Vision java web hosting services
This entry was posted
on Tuesday, January 16th, 2007 at 10:12 am and is filed under developing.
You can follow any responses to this entry through the RSS 2.0 feed.
Responses are currently closed, but you can trackback from your own site.