赞
踩
package com.zking.test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.Scanner;
import javax.swing.JOptionPane;
/**
* 添加学生的JDBC
* @author T283
*
*/
public class AddStu_JDBC {
public static void main(String[] args) throws Exception {
//1、注册驱动类
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
//2、连接数据库:字符串写错 会报错-对象无效
Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=T283", "sa", "123");
System.out.println(con);
//3、创建Statement对象(用来执行sql语句)
Scanner sc = new Scanner(System.in);
System.out.println("请输入用户名:");
String name = sc.next();
System.out.println("请输入性别:"
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。