没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
import java.sql.*;
public class TestJDBC {
public static void main(String[] args) {
// 用命令行参数输入三个字符串,把字符串内容插入表的相应字段
// 本程序的要插入表有三个字段,第一个是数字类型,第二和第三个为字符类型
if (args.length != 3) {
System.out.println("参数错误");
System.exit(-1);
}
int id = 0;
try {
//处理第一个字符串不能转换为数字的异常
id = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
e.printStackTrace();
System.exit(-1);
}
String name = args[1];
String introduction = args[2];
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName("com.mysql.jdbc.Driver");
// con =
// DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb?user=root&password=root");
con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/mydb", "root", "root");
stmt = con.createStatement();
public class TestJDBC {
public static void main(String[] args) {
// 用命令行参数输入三个字符串,把字符串内容插入表的相应字段
// 本程序的要插入表有三个字段,第一个是数字类型,第二和第三个为字符类型
if (args.length != 3) {
System.out.println("参数错误");
System.exit(-1);
}
int id = 0;
try {
//处理第一个字符串不能转换为数字的异常
id = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
e.printStackTrace();
System.exit(-1);
}
String name = args[1];
String introduction = args[2];
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName("com.mysql.jdbc.Driver");
// con =
// DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb?user=root&password=root");
con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/mydb", "root", "root");
stmt = con.createStatement();
资源评论
俺爱吃萝卜
- 粉丝: 9
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功