Bookmark Topic Watch Topic
  • New Topic

lass name is wrong or classpath is not set  RSS feed

 
Siddhant Mahajan
Greenhorn
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 : 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
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!