1、mysql+myeclipes+win7的数据库测试图1安装开始图2 接受安装图3 典型安装图4 装载上图为一个 可视化的与SQL结合的工具导入包:my-sql-connector-java-3.1.10-bin.jar代码如下:package com.jdbc;import java.sql.*;import java.sql.Connection;import java.sql.DriverManager;public class TestConn public static void main(String args) / TODO Auto-generated method stub
2、String drv=org.gjt.mm.mysql.Driver; String url=jdbc:mysql:/localhost:3306/Demo; String usr=root; String pwd=123456; String sql=select *from users; try Class.forName(drv).newInstance(); Connection conn=DriverManager.getConnection(url,usr,pwd); Statement stm=conn.createStatement(); ResultSet rs=stm.ex
3、ecuteQuery(sql); ResultSetMetaData rsmd=rs.getMetaData(); int cols=rsmd.getColumnCount(); while(rs.next() for(int i=1;i=cols;i+) String field=(String)(rsmd.getColumnName(i); String value=(String)(rs.getString(i); System.out.println(field+=+value); rs.close(); stm.close(); conn.close(); catch(Exception e) e.printStackTrace(); System.out.print(e);