Bookmark Topic Watch Topic
  • New Topic

lass name is wrong or classpath is not set  RSS feed

Siddhant Mahajan
Posts: 2
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi, i'm newbe in JDBC and i need somehelp here if it is possible.

I m using netbeans 6.5.1 with glassfish v2 server

The error showing is ::: Class name is wrong or classpath is not set for :

this error is shown when i run the servlet file and is shown in the browser window
Sun resource shows ::
<jdbc-resource enabled="true" jndi-name="jdbc/myDatasource" object-type="user" pool-name="connectionPool">
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="connectionPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<property name="URL" value="jdbc:sun:sqlserver://server_name[:portNumber];databaseName=database;selectMethod=cursor"/>
<property name="User" value="sa"/>
<property name="Password" value="niit"/>
<property name="databaseName" value="mydb1"/>
<property name="serverName" value="PCV"/>
<property name="portNumber" value="1437"/>


And the servlet file is ::
package sp;

*import javax.servlet.;
*import java.sql.;
*import javax.naming.;
*import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;

public class servlet2 extends HttpServlet {

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
try {
out.println("<title>Servlet servlet2</title>");
DataSource ds = null;
Context myc = new InitialContext();
ds = (DataSource) myc.lookup("jdbc/myDatasource");
Connection con = ds.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select prod_id from mytable1");
catch(Exception e){
out.println("THE ERROR IS : " e);

} finally {

also i hv copied these files to the lib folder of glassfish server v2 and then set the class suffix as

in the glassfish server admin console

could anyone please help me
i can mail the whole project if needed
Bear Bibeault
Author and ninkuma
Posts: 65833
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place. Please read this for more information.
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!