如题,还有最新版本的可视化MySQL是哪个,可以将具体的使用JDBC驱动Java连接MySQL的具体操作具体流程说一下
解决方案 »
- mysql多表用别名的方式查询时,到底与用左联,右联查询区别在哪里?
- \MySQL Server 5.5 主从同步报错unknown variable 'master-host=192.168.8.111'
- Mysql noinstall 那些文件可以 删除掉 还能正常 使用呢?
- SELECT语句怎么实现这样的过滤?
- mysql 批量新增例名时,会出错..怪事
- 关于编码
- win下mysql管理密码忘了怎么办?
- 关于MySQL中有些表只读的问题
- mysql数据库可以托管维护吗
- [求助]在mysql里面采样
- sqlserver 中,select * from tabl1 with nolock.可以提高查询性能。mysql如何?
- MySQL出现乱码问题,请教!!!
Import java.sql.*;public class SampleIntro
{
public static void main(String[] args)
{
try
{
Connection conn;
Statement stmt;
ResultSet res;
//加载Connector/J驱动
//这一句也可写为:Class.forName("com.mysql.jdbc.Driver");
Class.forName("com.mysql.jdbc.Driver").newInstance();
//建立到MySQL的连接
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test",
"root", "guapo");
//执行SQL语句
stmt = conn.createStatement();
res = stmt.executeQuery("select * from pet");
//处理结果集
while (res.next())
{
String name = res.getString("name");
System.out.println(name);
}
res.close(); }
catch (Exception ex)
{
System.out.println("Error : " + ex.toString());
}
}
}
没有可视化MySQL,MYSQL只是个数据库管理系统。没有人机界面。
你需要的GUI管理工具可以到官网下载。
http://dev.mysql.com/downloads/gui-tools/5.0.html
Connector/J 5.1
http://dev.mysql.com/downloads/connector/j/5.1.html
http://dev.mysql.com/downloads/connector/j/5.1.html
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;Connection conn = null;
...
try {
conn =
DriverManager.getConnection("jdbc:mysql://localhost/test?" +
"user=monty&password=greatsqldb"); // Do something with the Connection ...
} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
官方手册中就有例子。21.4.3. Connector/J Examples
Examples of using Connector/J are located throughout this document, this section provides a summary and links to these examples. Example 21.1, “Connector/J: Obtaining a connection from the DriverManager” Example 21.2, “Connector/J: Using java.sql.Statement to execute a SELECT query” Example 21.3, “Connector/J: Calling Stored Procedures” Example 21.4, “Connector/J: Using Connection.prepareCall()” Example 21.5, “Connector/J: Registering output parameters” Example 21.6, “Connector/J: Setting CallableStatement input parameters” Example 21.7, “Connector/J: Retrieving results and output parameter values” Example 21.8, “Connector/J: Retrieving AUTO_INCREMENT column values using Statement.getGeneratedKeys()” Example 21.9, “Connector/J: Retrieving AUTO_INCREMENT column values using SELECT LAST_INSERT_ID()” Example 21.10, “Connector/J: Retrieving AUTO_INCREMENT column values in Updatable ResultSets” Example 21.11, “Connector/J: Using a connection pool with a J2EE application server” Example 21.12, “Connector/J: Example of transaction with retry logic”