Java连接mysql数据库源代码
时间:2025-06-19
时间:2025-06-19
本程序使用Java+Mysql进行编写,其中主要是对数据库进行数据的更新及维护工作,主要界面为DOS界面,如有兴趣的同仁,可修改成GUI界面的,方便进行操作及管理。
Java连接mysql数据库源代码
/**
*@author mervyn
*@Development_time 2011.3.12
*welcome to /mervyn_hb
*/
package src;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.sql.*;
import java.util.*;
public class MysqlConnectSystem {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws SQLException, IOException {
String Usename,KeyID,UrlString;
//String DriverConnect;
char MenuExitValue;
String driver="com.mysql.jdbc.Driver";
Scanner EntryValue=new Scanner(System.in);
System.out.println("欢迎使用MysqlConnectSystem信息管理系统!"); MysqlConnectSystem mysqlconnect=new MysqlConnectSystem(); MysqlConnectSystem mysqlinsert=new MysqlConnectSystem(); MysqlConnectSystem mysqlupdate=new MysqlConnectSystem(); MysqlConnectSystem mysqldelete=new MysqlConnectSystem();
System.out.println("请输入要登录的用户名:");
Usename=EntryValue.next();
System.out.println("请输入要登录的数据库的密码:"); KeyID=EntryValue.next();
System.out.println("请输入需要登录的数据库:");
UrlString="jdbc:mysql://127.0.0.1:3306/"+EntryValue.next(); do{
try {
Class.forName(driver);
Connection conn=DriverManager.getConnection(UrlString, Usename,
上一篇:韩国兵役制度
下一篇:民营中小企业人事管理初探