
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.SQLException;
// User: USER
// Datetime: Thu Oct 20 15:19:38 IST 2011
// File name: Document [1].java
/**
* This class is generated from template.
* To change the template go to Window -> Preferences -> Document Template.
* @author Apex Text
*/
public class A{
private A(){
}
public static void main(String args[]) throws Exception{
Connection connection=getConnection();
Statement st=null;
ResultSet rs=null;
try {
st=connection.createStatement();
rs=st.executeQuery("select count(*) from employee");
rs.next();
int employeeCount=rs.getInt(1);
System.out.println("Employee count: "+employeeCount);
}finally{
if(st!=null){
st.close();
}
if(rs!=null){
rs.close();
}
if(connection!=null){
}
}
}
public static Connection getConnection() {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/abhi","psuggest","");
} catch (SQLException ex){
ex.printStackTrace();
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
return con;
}
}
"is the program with database created and compilation is sucessful
but when we run application i have an error message like this..."
(""""""Java Tools >> Run Application' tool executing...
java.lang.NoClassDefFoundError: A
Caused by: java.lang.ClassNotFoundException: A
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: A. Program will exit.
Exception in thread "main"
'Java Tools >> Run Application' tool execution finished."""""")
what may the problem?
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.