Once you have extracted the distribution archive, you can
install the driver by placing
mysql-connector-java-[version]-bin.jar
in
your classpath, either by adding the full path to it to your
CLASSPATH
environment variable, or by
directly specifying it with the command line switch -cp when
starting your JVM.
If you are going to use the driver with the JDBC DriverManager,
you would use com.mysql.jdbc.Driver
as the
class that implements java.sql.Driver.
You can set the CLASSPATH
environment
variableunder UNIX, Linux or Mac OS X either locally for a user
within their .profile
,
.login
or other login file. You can also set
it globally by editing the global
/etc/profile
file.
For example, under a C shell (csh, tcsh) you would add the
Connector/J driver to your CLASSPATH
using
the following:
shell> setenv CLASSPATH /path/mysql-connector-java-[ver]-bin.jar:$CLASSPATH
Or with a Bourne-compatible shell (sh, ksh, bash):
export set CLASSPATH=/path/mysql-connector-java-[ver]-bin.jar:$CLASSPATH
Within Windows 2000, Windows XP and Windows Server 2003, you must set the environment variable through the System control panel.
If you want to use MySQL Connector/J with an application server
such as Tomcat or JBoss, you will have to read your vendor's
documentation for more information on how to configure
third-party class libraries, as most application servers ignore
the CLASSPATH
environment variable. For
configuration examples for some J2EE application servers, see
Sección 25.4.5.2, “Using Connector/J with J2EE and Other Java Frameworks”. However, the
authoritative source for JDBC connection pool configuration
information for your particular application server is the
documentation for that application server.
If you are developing servlets or JSPs, and your application server is J2EE-compliant, you can put the driver's .jar file in the WEB-INF/lib subdirectory of your webapp, as this is a standard location for third party class libraries in J2EE web applications.
You can also use the MysqlDataSource or
MysqlConnectionPoolDataSource classes in the
com.mysql.jdbc.jdbc2.optional
package, if
your J2EE application server supports or requires them. Starting
with Connector/J 5.0.0, the
javax.sql.XADataSource
interface is
implemented via the
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
class, which supports XA distributed transactions when used in
combination with MySQL server version 5.0.
The various MysqlDataSource classes support the following parameters (through standard set mutators):
user
password
serverName (see the previous section about fail-over hosts)
databaseName
port
Ésta es una traducción del manual de referencia de MySQL, que puede encontrarse en dev.mysql.com. El manual de referencia original de MySQL está escrito en inglés, y esta traducción no necesariamente está tan actualizada como la versión original. Para cualquier sugerencia sobre la traducción y para señalar errores de cualquier tipo, no dude en dirigirse a mysql-es@vespito.com.