Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- import java.util.*;
- class InputSeeker{
- Scanner sc = new Scanner(System.in);
- // Name seeker
- public String nameSeeker(){
- System.out.println("Enter the Name you want to add: ");
- String name = sc.next();
- return name;
- }
- // id seeker
- public int idSeeker() {
- System.out.println("Assign the Participant an id : ");
- int id= sc.nextInt();
- return id;
- }
- //number seeker
- public float amountSpentSeeker() {
- System.out.println("Enter the amount: ");
- float amountSpent= sc.nextFloat();
- return amountSpent;
- }
- //mobile number
- public String mobileNumberSeeker() {
- System.out.println("Enter the mobile number: ");
- String mobileNumber=sc.next();
- return mobileNumber;
- }
- //group id
- public int groupIdSeeker() {
- System.out.println("Assign the Group an id: ");
- int groupid= sc.nextInt();
- return groupid;
- }
- }
- class UserL{
- int userId;
- String userName;
- float amountSpent;
- String mobileNumber;
- int groupId;
- }
- class UserDAO{
- Connection con =null;
- public void connect(){
- try {
- Class.forName("com.mysql.jdbc.Driver");
- con= DriverManager.getConnection("jdbc:mysql://localhost:3306/markone","root","nishant97");
- } catch (Exception ex) {
- System.out.println(ex);
- }
- }
- public void addUser_catalogue(UserL u) {
- String query ="insert into user_catalogue value(?,?,?,?)";
- try {
- PreparedStatement pst = con.prepareStatement(query);
- pst.setInt(1,u.userId);
- pst.setString(2,u.userName);
- pst.setInt(3,u.groupId);
- pst.executeUpdate();
- } catch (Exception ex) {
- System.out.println(ex);
- }
- }
- }
- public class User{
- public static void main(String[] args){
- UserDAO dao = new UserDAO();
- dao.connect();
- UserL ul2= new UserL();
- InputSeeker is1 = new InputSeeker();
- ul2.userId=is1.id;
- }
- }
Add Comment
Please, Sign In to add comment