-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathVERIFY_VOTER.java
More file actions
83 lines (69 loc) · 2.34 KB
/
VERIFY_VOTER.java
File metadata and controls
83 lines (69 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
@Auther-Amrit Raj, Arpit Singh
*/
package LOADER;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.*;
import java.util.Scanner;
/**
*
* @author Arpit
*/
public class VERIFY_VOTER {
String Scholar_Id,Name,Branch ;
int Verify;
public String displayData(String sc)
{
try(Connection conn = connect();
Statement stat = conn.createStatement())
{
boolean hasResultSet = stat.execute("SELECT * FROM Student WHERE Scholar_Id="+sc);
if(hasResultSet)
{
Connection con = connect();
Statement stmt = con.createStatement();
System.out.println("Connection Established!");
ResultSet rs= stmt.executeQuery("SELECT Name FROM Student WHERE Scholar_Id="+sc);
System.out.println("Query Executed!");
rs.next();
System.out.println("Returning String name...!");
return ( rs.getString("Name") );
//return "Student found";
}
else{
return "Student not found!";
}
}
catch(Exception e)
{
System.out.println(e);
return String.valueOf(e);
}
}
//create a connection to a database
private Connection connect()
{
try
{
Class.forName("com.mysql.cj.jdbc.Driver");
DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
System.out.println("Connection Establishing.....!");
return DriverManager.getConnection("jdbc:mysql://localhost:5000/evm_nits?autoReconnect=true&useSSL=false","root","Arpit@123");//3306
}
catch(SQLException | ClassNotFoundException e)
{
System.out.println(e);
return null;
}
}
}