I'm creating dynamic web project that I am working on /servlet app .keep getting this error . I've tried many methods.Still, the error persists. What is strange is if I start typing the package name eclipse actually auto-completes the class for me! how to resolve this issue...I'm getting error at "database" keyword in jsp code. it keep showing error: "DatabaseConnection cannot resolved."
[the red under line is the key word where I get error][1]
this is code of database
package com.connection;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
public class DatabaseConnection {
//Creating Connection
public static Connection connection;
//Creating universal method to open connect will mysql database
public static Connection getConnection() {
try {
//Registering with mysql Driver
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://localhost:3308/shoppingsystem", "root", "Narend-10");
} catch (Exception e) {
e.printStackTrace();
}
return (connection);
}
//Creating universal method to close connect will mysql database
public static void CloseConnection() {
if (connection != null) {
try {
connection.close();
connection = null;
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
//Creating universal method to query for retriving information
public static ResultSet getResultFromSqlQuery(String SqlQueryString) {
//Creating Resultset object
ResultSet rs = null;
try {
//Checking whether the connection is null or null
if (connection == null) {
getConnection();
}
//Querying the query
rs = connection.createStatement().executeQuery(SqlQueryString);
} catch (Exception ex) {
ex.printStackTrace();
}
return rs;
}
//Creating universal method to query for inserting or updating information in mysql database
public static int insertUpdateFromSqlQuery(String SqlQueryString) {
int i = 2;
try {
//Checking whether the connection is null or null
if (connection == null) {
getConnection();
}
//Querying the query
i = connection.createStatement().executeUpdate(SqlQueryString);
} catch (Exception ex) {
ex.printStackTrace();
}
return i;
}
}
}
}
this code for jsp
<%
ResultSet resultOrders=DatabaseConnection.getResultFromSqlQuery("select * from tblorders where order_status='Pending'");
while (resultOrders.next()) {
%>
[1]: https://i.stack.imgur.com/GJbtg.png