• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Class name is wrong or classpath is not set

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • 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 : com.microsoft.sql.jdbcx.sqlserver.SQLServerDataSource

this error is shown when i run the servlet file and is shown in the browser window
Sun resource shows ::
---------------------------------------------------
<resources>
<jdbc-resource enabled="true" jndi-name="jdbc/myDatasource" object-type="user" pool-name="connectionPool">
<description/>
</jdbc-resource>
<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="com.microsoft.sql.jdbcx.sqlserver.SQLServerDataSource" 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"/>
</jdbc-connection-pool>
</resources>

----------------------------------

And the servlet file is ::
-----------------------------------
package sp;

import java.io.;
*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 {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet servlet2</title>");
out.println("</head>");
out.println("<body>");
try{
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");
while(rs.next()){
out.println(rs.getString(1)"
");
}
}
catch(Exception e){
out.println("THE ERROR IS : " e);
}
out.println("</body>");
out.println("</html>");

} finally {
out.close();
}
}

--------------------------------------------
also i hv copied these files to the lib folder of glassfish server v2 and then set the class suffix as
$(com.sun.aas.installRoot)/lib/msbase.jar
$(com.sun.aas.installRoot)/lib/msutil.jar
$(com.sun.aas.installRoot)/lib/mssqlserver.jar.

in the glassfish server admin console
--------------------------------------------

could anyone please help me
i can mail the whole project if needed
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to ask IDE questions in the IDEs forum. I have moved this post there for you.
reply
    Bookmark Topic Watch Topic
  • New Topic