工作中操作mysql的界面
MySQL是一种常用的关系型数据库管理系统,在工作中常常需要操作MySQL来进行数据库维护和管理。在操作MySQL时,可以使用命令行界面或者图形化界面来完成操作。
图形化界面是一种可视化的MySQL客户端工具,其操作界面简洁直观,可以通过图形化的操作方式来完成数据库的维护和管理。下面是一段使用Java编写的操作MySQL的示例代码:
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class MySQLDemo { public static void main(String[] args) { Connection conn = null; Statement stmt = null; ResultSet rs = null; try { Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "123456"); stmt = conn.createStatement(); rs = stmt.executeQuery("select * from users"); while (rs.next()) { System.out.println(rs.getString("username") + "----" + rs.getString("password")); } } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (rs != null) rs.close(); if (stmt != null) stmt.close(); if (conn != null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } }