rainycaptain
rainycaptain
JCHJava Community | Help. Code. Learn.
Created by yvtf on 1/14/2025 in #java-help
question
Why are you using scanner for your file?
14 replies
JCHJava Community | Help. Code. Learn.
Created by rainycaptain on 1/15/2025 in #java-help
Trying to connect to MS Access
No description
16 replies
JCHJava Community | Help. Code. Learn.
Created by rainycaptain on 1/15/2025 in #java-help
Trying to connect to MS Access
table^
16 replies
JCHJava Community | Help. Code. Learn.
Created by rainycaptain on 1/15/2025 in #java-help
Trying to connect to MS Access
No description
16 replies
JCHJava Community | Help. Code. Learn.
Created by rainycaptain on 1/15/2025 in #java-help
Trying to connect to MS Access
No description
16 replies
JCHJava Community | Help. Code. Learn.
Created by rainycaptain on 1/15/2025 in #java-help
Trying to connect to MS Access
This is the code^
16 replies
JCHJava Community | Help. Code. Learn.
Created by rainycaptain on 1/15/2025 in #java-help
Trying to connect to MS Access
package Database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class mark {
public static void main(String[] args) {
// Correct JDBC URL format for UCanAccess
String dataBaseURL = "jdbc:ucanaccess:
StudentMarkDatabase\\src\\Database\\Marks Database.accdb";

try {
// Register the JDBC driver
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");

// Establish the connection
Connection conn = DriverManager.getConnection(dataBaseURL);

// Create a statement
Statement statement = conn.createStatement();

// Execute the query
String query = "SELECT * FROM tblStudents"; // Ensure correct table name case sensitivity
ResultSet resultSet = statement.executeQuery(query);

// Process the result set
while (resultSet.next()) {
int stuID = resultSet.getInt("StuID");
String firstName = resultSet.getString("FirstName");
String lastName = resultSet.getString("LastName");
String userName = resultSet.getString("UserName");
String password = resultSet.getString("Password");
String dob = resultSet.getString("DOB");

System.out.println("StuID: " + stuID + ", FirstName: " + firstName + ", LastName: " + lastName +
", UserName: " + userName + ", Password: " + password + ", DOB: " + dob);
}

// Close the resources
resultSet.close();
statement.close();
conn.close();

} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
package Database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class mark {
public static void main(String[] args) {
// Correct JDBC URL format for UCanAccess
String dataBaseURL = "jdbc:ucanaccess:
StudentMarkDatabase\\src\\Database\\Marks Database.accdb";

try {
// Register the JDBC driver
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");

// Establish the connection
Connection conn = DriverManager.getConnection(dataBaseURL);

// Create a statement
Statement statement = conn.createStatement();

// Execute the query
String query = "SELECT * FROM tblStudents"; // Ensure correct table name case sensitivity
ResultSet resultSet = statement.executeQuery(query);

// Process the result set
while (resultSet.next()) {
int stuID = resultSet.getInt("StuID");
String firstName = resultSet.getString("FirstName");
String lastName = resultSet.getString("LastName");
String userName = resultSet.getString("UserName");
String password = resultSet.getString("Password");
String dob = resultSet.getString("DOB");

System.out.println("StuID: " + stuID + ", FirstName: " + firstName + ", LastName: " + lastName +
", UserName: " + userName + ", Password: " + password + ", DOB: " + dob);
}

// Close the resources
resultSet.close();
statement.close();
conn.close();

} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
16 replies
JCHJava Community | Help. Code. Learn.
Created by rainycaptain on 1/15/2025 in #java-help
Trying to connect to MS Access
It's happening whenever I try to access whats inside a table in the database
16 replies
JCHJava Community | Help. Code. Learn.
Created by rainycaptain on 1/15/2025 in #java-help
Trying to connect to MS Access
I fixed this error, I'm experiencing another one. Is it okay for me to send it here or should I make a new help post?
16 replies
CC#
Created by Astraxes on 1/13/2025 in #help
Help with C# student task
it would help if you posted the task as well
21 replies
JCHJava Community | Help. Code. Learn.
Created by rainycaptain on 1/11/2025 in #java-help
pathFinding algorithm will not find path?
5 replies