package com.frank.dbdemo.util;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PReparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.sql.DataSource;public class TestUtil { public static void sample() { try { Class.forName(com.MySQL.jdbc.Driver.class.getName()); String url = "jdbc:mysql://10.8.64.53:3306/card?characterEncoding=utf-8"; String user = "work@RR"; String passWord = "Geeker4ZolZ"; Connection conn = DriverManager.getConnection(url, user, password); String sql = "select count(*) from card_verify"; Statement statement = conn.createStatement(); ResultSet rs = statement.executeQuery(sql); while (rs.next()) { System.out.println(rs.getInt(1)); } } catch (Exception e) { e.printStackTrace(); } System.out.println("Query ended."); }}
新闻热点
疑难解答