How to add database for a java project ? and for individual class and method how can i add this? [on hold]











up vote
-4
down vote

favorite












public class Student extends DBConnection { public long getActiveEnrolledStudentsCount(long semesterId, long levelId, int studentCampus, long curriculumid, long programmeid, long adminId)
throws ClassNotFoundException, SQLException
{
long studentcount = 0;

String sqlstr = "";
if (semesterId > 0){
sqlstr = sqlstr + " AND SM.endDate>=R.startDate AND SM.startDate<=R.endDate AND C.semesterId=" + semesterId;
}

if (programmeid > 0){
sqlstr = sqlstr + " AND R.programmeId=" + programmeid;
}

if (levelId > 0) {
sqlstr = sqlstr + " AND R.levelId=" + levelId;
}

if (curriculumid > -1) {
sqlstr = sqlstr + " AND R.curriculumId=" + curriculumid;
}

if (openDB()){
String subAdminCampusSelection = (subadminCampusList != null && !subadminCampusList.equals("")) ? " AND S.studentCampus in (" + subadminCampusList + ") ": "";
if(studentCampus >= 0){
subAdminCampusSelection = " AND S.studentCampus = " + studentCampus;
}

// Execute the query
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT COUNT(DISTINCT S.studentId) AS STUDENTCOUNT FROM Classes C, ClassStudentReltn CSR, Students S, Registrations R, Semesters SM WHERE C.isActive=1 AND R.isActive=1 AND SM.semesterId=C.semesterId " + sqlstr + subAdminCampusSelection + " AND C.classId=CSR.classId AND CSR.isActive=1 AND CSR.studentId=S.studentId AND R.studentId=CSR.studentId AND S.adminId=" + adminId);

// Populate user information
if (rs.next()) {
studentcount = rs.getLong(rs.findColumn("STUDENTCOUNT"));
}
closeDB();
}

return studentcount;
}
}









share|improve this question









New contributor




JUMAER AHAMED is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as unclear what you're asking by t3chb0t, Heslacher, Graipher, Toby Speight, BCdotWEB 2 days ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.















  • Questions asking for advice about code not yet written are off-topic. Please follow the tour and read "How do I ask a good question?", "What topics can I ask about here?" and "What types of questions should I avoid asking?".
    – BCdotWEB
    2 days ago















up vote
-4
down vote

favorite












public class Student extends DBConnection { public long getActiveEnrolledStudentsCount(long semesterId, long levelId, int studentCampus, long curriculumid, long programmeid, long adminId)
throws ClassNotFoundException, SQLException
{
long studentcount = 0;

String sqlstr = "";
if (semesterId > 0){
sqlstr = sqlstr + " AND SM.endDate>=R.startDate AND SM.startDate<=R.endDate AND C.semesterId=" + semesterId;
}

if (programmeid > 0){
sqlstr = sqlstr + " AND R.programmeId=" + programmeid;
}

if (levelId > 0) {
sqlstr = sqlstr + " AND R.levelId=" + levelId;
}

if (curriculumid > -1) {
sqlstr = sqlstr + " AND R.curriculumId=" + curriculumid;
}

if (openDB()){
String subAdminCampusSelection = (subadminCampusList != null && !subadminCampusList.equals("")) ? " AND S.studentCampus in (" + subadminCampusList + ") ": "";
if(studentCampus >= 0){
subAdminCampusSelection = " AND S.studentCampus = " + studentCampus;
}

// Execute the query
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT COUNT(DISTINCT S.studentId) AS STUDENTCOUNT FROM Classes C, ClassStudentReltn CSR, Students S, Registrations R, Semesters SM WHERE C.isActive=1 AND R.isActive=1 AND SM.semesterId=C.semesterId " + sqlstr + subAdminCampusSelection + " AND C.classId=CSR.classId AND CSR.isActive=1 AND CSR.studentId=S.studentId AND R.studentId=CSR.studentId AND S.adminId=" + adminId);

// Populate user information
if (rs.next()) {
studentcount = rs.getLong(rs.findColumn("STUDENTCOUNT"));
}
closeDB();
}

return studentcount;
}
}









share|improve this question









New contributor




JUMAER AHAMED is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as unclear what you're asking by t3chb0t, Heslacher, Graipher, Toby Speight, BCdotWEB 2 days ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.















  • Questions asking for advice about code not yet written are off-topic. Please follow the tour and read "How do I ask a good question?", "What topics can I ask about here?" and "What types of questions should I avoid asking?".
    – BCdotWEB
    2 days ago













up vote
-4
down vote

favorite









up vote
-4
down vote

favorite











public class Student extends DBConnection { public long getActiveEnrolledStudentsCount(long semesterId, long levelId, int studentCampus, long curriculumid, long programmeid, long adminId)
throws ClassNotFoundException, SQLException
{
long studentcount = 0;

String sqlstr = "";
if (semesterId > 0){
sqlstr = sqlstr + " AND SM.endDate>=R.startDate AND SM.startDate<=R.endDate AND C.semesterId=" + semesterId;
}

if (programmeid > 0){
sqlstr = sqlstr + " AND R.programmeId=" + programmeid;
}

if (levelId > 0) {
sqlstr = sqlstr + " AND R.levelId=" + levelId;
}

if (curriculumid > -1) {
sqlstr = sqlstr + " AND R.curriculumId=" + curriculumid;
}

if (openDB()){
String subAdminCampusSelection = (subadminCampusList != null && !subadminCampusList.equals("")) ? " AND S.studentCampus in (" + subadminCampusList + ") ": "";
if(studentCampus >= 0){
subAdminCampusSelection = " AND S.studentCampus = " + studentCampus;
}

// Execute the query
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT COUNT(DISTINCT S.studentId) AS STUDENTCOUNT FROM Classes C, ClassStudentReltn CSR, Students S, Registrations R, Semesters SM WHERE C.isActive=1 AND R.isActive=1 AND SM.semesterId=C.semesterId " + sqlstr + subAdminCampusSelection + " AND C.classId=CSR.classId AND CSR.isActive=1 AND CSR.studentId=S.studentId AND R.studentId=CSR.studentId AND S.adminId=" + adminId);

// Populate user information
if (rs.next()) {
studentcount = rs.getLong(rs.findColumn("STUDENTCOUNT"));
}
closeDB();
}

return studentcount;
}
}









share|improve this question









New contributor




JUMAER AHAMED is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











public class Student extends DBConnection { public long getActiveEnrolledStudentsCount(long semesterId, long levelId, int studentCampus, long curriculumid, long programmeid, long adminId)
throws ClassNotFoundException, SQLException
{
long studentcount = 0;

String sqlstr = "";
if (semesterId > 0){
sqlstr = sqlstr + " AND SM.endDate>=R.startDate AND SM.startDate<=R.endDate AND C.semesterId=" + semesterId;
}

if (programmeid > 0){
sqlstr = sqlstr + " AND R.programmeId=" + programmeid;
}

if (levelId > 0) {
sqlstr = sqlstr + " AND R.levelId=" + levelId;
}

if (curriculumid > -1) {
sqlstr = sqlstr + " AND R.curriculumId=" + curriculumid;
}

if (openDB()){
String subAdminCampusSelection = (subadminCampusList != null && !subadminCampusList.equals("")) ? " AND S.studentCampus in (" + subadminCampusList + ") ": "";
if(studentCampus >= 0){
subAdminCampusSelection = " AND S.studentCampus = " + studentCampus;
}

// Execute the query
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT COUNT(DISTINCT S.studentId) AS STUDENTCOUNT FROM Classes C, ClassStudentReltn CSR, Students S, Registrations R, Semesters SM WHERE C.isActive=1 AND R.isActive=1 AND SM.semesterId=C.semesterId " + sqlstr + subAdminCampusSelection + " AND C.classId=CSR.classId AND CSR.isActive=1 AND CSR.studentId=S.studentId AND R.studentId=CSR.studentId AND S.adminId=" + adminId);

// Populate user information
if (rs.next()) {
studentcount = rs.getLong(rs.findColumn("STUDENTCOUNT"));
}
closeDB();
}

return studentcount;
}
}






java random






share|improve this question









New contributor




JUMAER AHAMED is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




JUMAER AHAMED is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago









Heslacher

44.7k460155




44.7k460155






New contributor




JUMAER AHAMED is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









JUMAER AHAMED

1




1




New contributor




JUMAER AHAMED is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





JUMAER AHAMED is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






JUMAER AHAMED is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as unclear what you're asking by t3chb0t, Heslacher, Graipher, Toby Speight, BCdotWEB 2 days ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






put on hold as unclear what you're asking by t3chb0t, Heslacher, Graipher, Toby Speight, BCdotWEB 2 days ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • Questions asking for advice about code not yet written are off-topic. Please follow the tour and read "How do I ask a good question?", "What topics can I ask about here?" and "What types of questions should I avoid asking?".
    – BCdotWEB
    2 days ago


















  • Questions asking for advice about code not yet written are off-topic. Please follow the tour and read "How do I ask a good question?", "What topics can I ask about here?" and "What types of questions should I avoid asking?".
    – BCdotWEB
    2 days ago
















Questions asking for advice about code not yet written are off-topic. Please follow the tour and read "How do I ask a good question?", "What topics can I ask about here?" and "What types of questions should I avoid asking?".
– BCdotWEB
2 days ago




Questions asking for advice about code not yet written are off-topic. Please follow the tour and read "How do I ask a good question?", "What topics can I ask about here?" and "What types of questions should I avoid asking?".
– BCdotWEB
2 days ago















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

List directoties down one level, excluding some named directories and files

list processes belonging to a network namespace

list systemd RuntimeDirectory mounts