首页 > 学院 > 开发设计 > 正文

Java jdbc操作myql入门

2019-11-14 10:37:12
字体:
来源:转载
供稿:网友

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.");	}}


上一篇:springMVC简单学习

下一篇:java io

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表