⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 registration.java

📁 it is a tool forregistration nd other things in java
💻 JAVA
字号:
import java.util.*;
import java.sql.*;


public class registration
{
	static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
	static final String DATABASE_URL = "jdbc:mysql://localhost/chatserver";
	public static void main(String args[]) throws Exception
	{
		Scanner input = new Scanner (System.in);
		String user_id,password,email,answer;
		int question;
		
		user_id = input.next();
		password = input.next();
		email = input.next();
		question = input.nextInt();
		answer = input.next();
		connect(user_id,password,email,answer,question);
	}
	
	public static void connect(String user_id, String password,String email,String answer,int question)
	{
		Connection connection = null;
		Statement statement = null;
		
		try{
			Class.forName(JDBC_DRIVER);
			
			connection = DriverManager.getConnection(DATABASE_URL,"root","");
			statement = connection.createStatement();
			statement.executeUpdate("INSERT INTO tbl_registereduser VALUES('"+user_id+"','"+password+"','"+email+"',"+question+",'"+answer+"',0)");
		}
		catch (SQLException sqlException)
		{
			sqlException.printStackTrace();
			System.exit(1);
		}
		catch (ClassNotFoundException classNotFound)
		{
			classNotFound.printStackTrace();
			System.exit(1);
		}
		
		finally
		{
			try{
				statement.close();
				connection.close();
			}
			catch(Exception exception)
			{
				exception.printStackTrace();
				System.exit(1);
			}
		}
	} 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -