May 7th, 2008
Replication 18 1818 CHAPTER An area that has received a lot of attention from the MySQL development team has been replication. Replication refers to the automated copying of changes made to databases and data between two or more MySQL servers. The MySQL development team has made replication in MySQL a robust and stable feature. As part of my daily routine, I manage a fairly large-scale database that is replicated across five states in real time using MySQL replication. The system has been operational for two years with very little difficulty. Even two years ago, replication in MySQL was stable. The stability and added features of today s MySQL replication make it a good choice for redundancy and mission-critical applications alike. This chapter looks at MySQL replication, including how to install and configure replication between two or more MySQL servers. MySQL AB has gone to great lengths to make replication configuration easy as you ll see in the following pages. Planning and Preparing for Replication Before undertaking the tasks involved in actually setting up replication, take some time to plan and prepare for those tasks. The planning includes making sure replication is right for your implementation, deciding what databases or tables will be replicated, how many servers will participate in the replication, and how you will monitor replication. Preparing for replication includes ensuring that all participating servers are running on the same MySQL version. …. In This Chapter Getting ready for replication Setting your configurations for replication Keeping an eye on replication Using replication shortcuts ….
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.
Posted in Domain | No Comments »
May 6th, 2008
PART Advanced V VVPerformance …. In This Part Chapter 18 Replication Chapter 19 Integration of Internet Services Chapter 20 NuSphere Enhanced MySQL ….
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.
Posted in Domain | No Comments »
May 5th, 2008
Chapter 17 . ODBC/JDBC 521 Statement stmt = con.createStatement(); ResultSet productinfo = stmt.executeQuery( SELECT name,artist FROM product ); while (productinfo.next()) { System.out.println(productinfo.getString( name ) + + productinfo.getString( artist )); } You can save the program as SimpleSelect.javaand compile it by typing the following command: javac SimpleSelect.java Summary MyODBC is MySQL AB s version of an ODBC driver for MySQL, available for Windows and for some versions of Unix and Linux. . MyODBC can be obtained directly from MySQL AB s Web site. . MyODBC installation in Windows is straightforward using a standard Windows-type setup program. . During setup you enter in basic information about the MySQL ODBC Data Source including the name or IP of the server, username, password, and database to connect to. . You can change the information or add Data Sources for MySQL at a later time through the ODBC Control Panel in Windows. . Connecting MySQL to Microsoft Access is relatively simple and is done through the Get External Data process. . Connecting MySQL to Microsoft Word is done through the use of Microsoft Query to build a SELECT query for the data you d like to integrate. . JDBC is the Java equivalent of ODBC. JDBC is distributed with the Java Software Development Kit from Sun. . MySQL has a driver to integrate with the JDBC so you can connect MySQL to Java programs and applets. …
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.
Posted in Domain | No Comments »
May 4th, 2008
520 Part IV . Development Creating a basic MySQL JDBC Program Building on the simple connection program from the last section, I ll retrieve some results from a query by using the following code: import java.sql.*; public class SimpleSelect { public static void main(String args[]) { String url = jdbc:mysql://localhost/ecommerce ; Connection con; try { Class.forName( org.gjt.mm.mysql.Driver ); } catch(java.lang.ClassNotFoundException e) { System.err.print( ClassNotFoundException: ); System.err.println(e.getMessage()); } try { con = DriverManager.getConnection(url, suehring , evh5150 ); System.out.println( Connection established! ); Statement stmt = con.createStatement(); ResultSet productinfo = stmt.executeQuery( SELECT name,artist FROM product ); while (productinfo.next()) { System.out.println(productinfo.getString( name ) + + productinfo.getString( artist )); } con.close(); } catch(SQLException ex) { System.err.println( SQLException: + ex.getMessage()); } } } The code just given has a new section added to execute the statement and retrieve the results. A Statementobject, stmt, is created. Then the query is issued. The results are then retrieved by using the getString method with the column name in quotes:
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.
Posted in Domain | No Comments »
May 4th, 2008
Chapter 17 . ODBC/JDBC 519 You can save this connection as a program named FirstConnection.java and compile it by typing javac FirstConnection.java Once the program is compiled, you can run it by typing java FirstConnection When your first connection is successful, a Connection Successful message appears. Examining some of the code snippets reveals that a string variable, url, is initialized and contains the connection information for the server (localhost) that I want to connect to, along with the database (ecommerce) that I want to use. If I want to specify a port other than the default 3306, I can use localhost:port. For example, I could use localhost:5150like this: String url = jdbc:mysql://localhost/ecommerce ; A connection object, con, is created next: Connection con; The MySQL JDBC driver is now loaded, according to the syntax discussed in the previous section. If the loading of the driver is unsuccessful, an error message is printed; the following code displays the error message: try { Class.forName( org.gjt.mm.mysql.Driver ); } catch(java.lang.ClassNotFoundException e) { System.err.print( ClassNotFoundException: ); System.err.println(e.getMessage()); } The connection is attempted next; if it does not succeed, use SQLException to retrieve the error message. That operation looks like this: try { con = DriverManager.getConnection(url, suehring , evh5150 ); System.out.println( Connection established! ); con.close(); } catch(SQLException ex) { System.err.println( SQLException: + ex.getMessage()); } }
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.
Posted in Domain | No Comments »
May 3rd, 2008
518 Part IV . Development Cached connections Up to this point, I ve been showing examples using the ResultSetobject. The ResultSet object remains connected to the data source for result retrieval. Because the connection must remain intact and active, the ResultSetobject is not useful for working with data over a networked connection. The JDBC API defines a RowSet interface that includes a CachedRowSetclass that can be used to retrieve results and place them into a cache for later use. Connecting to MySQL with the JDBC API and MySQL Driver Connecting to MySQL with JDBC for the first time can be a humbling experience. After lurking on Java mailing lists for a long time (as well as watching the Usenet newsgroups), I ve seen numerous questions by first-time developers who struggle with this initial JDBC connection. The following code demonstrates a typical connection to a MySQL server, made with Java. import java.sql.*; public class FirstConnection { public static void main(String args[]) { String url = jdbc:mysql://localhost/ecommerce ; Connection con; try { Class.forName( org.gjt.mm.mysql.Driver ); } catch(java.lang.ClassNotFoundException e) { System.err.print( ClassNotFoundException: ); System.err.println(e.getMessage()); } try { con = DriverManager.getConnection(url, suehring , evh5150 ); System.out.println( Connection established! ); con.close(); } catch(SQLException ex) { System.err.println( SQLException: + ex.getMessage()); } } }
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.
Posted in Domain | No Comments »
May 2nd, 2008
Chapter 17 . ODBC/JDBC 517 System.out.println( Connection established! ); DatabaseMetaData dbmdata = con.getMetaData(); System.out.println( Database Information ); System.out.println( Database name: + dbmdata.getDatabaseProductName()) ; System.out.println( Version: + dbmdata.getDatabaseProductVersion()); System.out.println( Driver: + dbmdata.getDriverName()); System.out.println( Version: + dbmdata.getDriverVersion()); con.close(); } catch(SQLException ex) { System.err.println( SQLException: + ex.getMessage()); } } } Working with JDBC errors The main handler for errors with JDBC is SQLException class. SQLException, when invoked, sends a string with a description of the exception. This error message is retrieved with the getMessage()method. SQLException actually sends three pieces of information; in general terms, these are as follows: . Message string the message itself. . SQL state a five-character string retrieved with the getSQLState() method. . Vendor error code a code defined by the software vendor and retrieved with the getErrorCode()method. Testing for NULL values The wasNull() method serves to determine if a value returned from the database was NULL. The wasNull()method is called as part of the result set for a statement, as in the following example: Statement stmt = con.createStatement(); result = stmt.executeQuery(sql); while (result.next()) { if (result.wasNull()) { System.out.println( Null found. ); } }
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.
Posted in Domain | No Comments »
May 1st, 2008
516 Part IV . Development The getDate(), getTime(), and getTimestamp()methods all return date or time values. When using a getmethod, you provide the column name in quotes. For example, getString( columnname ); If you do not know the column name, you can identify the result with by its numerical column-position reference. If you don t know the number of columns, you can find that value in the realm of the upcoming section; it s a type of metadata. Database metadata To manipulate data, you need information about it metadata. Database metadata, for example, is information about the database and the data it contains for example, the number of columns returned from a query. There are two sets of metadata for JDBC objects connection and result. Both are retrieved with the getMetaData() method. When called in reference to a ResultSet, the ResultSetMetaData object type is returned. In answer to the question posed about the number of columns, the following code snippet shows how to determine the number of columns from a given result set. ResultSetMetaData databaseinfo = result.getMetaData(); int columns = databaseinfo.getColumnCount(); System.out.println(columns); Other useful methods within ResultSetMetaData are getColumnName(), and getColumnType(). Metadata about the database and server is available through the DatabaseMetaData object, as follows: import java.sql.*; public class DBMeta { public static void main(String args[]) { String url = jdbc:mysql://localhost/ecommerce ; Connection con; try { Class.forName( org.gjt.mm.mysql.Driver ); } catch(java.lang.ClassNotFoundException e) { System.err.print( ClassNotFoundException: ); System.err.println(e.getMessage()); } try { con = DriverManager.getConnection(url, suehring , evh5150 );
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.
Posted in Domain | No Comments »
April 30th, 2008
Chapter 17 . ODBC/JDBC 515 the getConnectionmethod. GetConnectiontakes a string URL as an argument. In the case of MySQL, you provide the URL and credentials for the connection: Connection con; con = DriverManager.getConnection(url, username , password ); Alternatively: Connection con = DriverManager.getConnection(url, username , password ); The basics of handling statements and results The Statementinterface with the JDBC is not an object, but rather, an interface for creating an object that executes statements. You create a Statementobject as follows: Statement stmt = connection.CreateStatement(); With the Statement object created, you use an execute method on the object. There are four execute methods for use with the JDBC: executeQuery(), executeUpdate(), executeBatch(), and execute(). The executeQuery()method is for statements such as SELECT that retrieve values from a database. The executeUpdate() method is used commonly with DDL statements that don t return values but may return a number of rows affected by the operation. Finally, the execute()method is for statements that return greater than one result or count. The executeUpdate() method returns an integer value that contains the number of rows affected by the operation. The results from queries are retrieved using ResultSet. For example: ResultSet result = statement.executeQuery( SELECT * FROM user ); To access the results, use a get method. The basic methods for accessing data are as follows: getBoolean() getByte() getDate() getDouble() getFloat() getInt() getLong() getShort() getString() getTime() getTimestamp()
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.
Posted in Domain | No Comments »
April 29th, 2008
514 Part IV . Development Figure 17-32: The error message given when the CLASSPATH variable hasn t been set For more information on installing and using the Java Software Development Kit, see the Sun Web site, http://java.sun.com. Using the JDBC and the MySQL Driver The JDBC itself defines the methods by which you connect to a database. This section looks at how to create a connection to a MySQL database and issue statements with the JDBC. Before doing so, I d like to go over some basic terminology and concepts. The concepts and terms of JDBC The first step involved in making the JDBC work with a database is loading a driver. The JDBC java.sql.DriverManagerclass performs this task. The DriverManager class also works with the Driver so you don t need to. The forName() method loads the Driver class. Note Although you can also load the Driver class by using jdbc.drivers, I recommend using the forName() method for the sake of consistency. The Class.forname() method takes a string as an argument. In the case of the MySQL JDBC driver, this string is: org.gjt.mm.mysql.Driver For example: Class.forName( org.gjt.mm.mysql.Driver ); The getConnectionmethod is called to make the actual connection to the database server. The DriverManager creates a Connection object when you call
You want to have a cheap webhost for your apache application, then check apache web hosting services.
Posted in Domain | No Comments »