cancel
Showing results for 
Search instead for 
Did you mean: 

SQLServerDriver java.lang.ClassNotFoundException?????

Former Member
0 Kudos

Hi there,

I am scratching my head as to why I am getting the following error when trying to connect from my Java Webdynpro to an SQL Server DB.

java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver

I have added the necessary JARS to the Webdynpro project:

msbase.jar

mssqlserver.jar

msutil.jar

And even when I open up the deployed EAR file and WDA archive I cannot see the JAR files inside them?

I am using a JNDI lookup for the real application but just for some quick testing I am needing to get this right.....

I have something like the following for the code....

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
		Connection con= DriverManager.getConnection( "jdbc:microsoft:sqlserver://<server>:<port>;databaseName=IDEA","lynton","password" ) ;
		Statement st = con.createStatement();
 
		String str = "SELECT * FROM Z_IDEA";
		ResultSet rs = st.executeQuery(str);
		while(rs.next())
		{
		String str1 = rs.getString("Subject");
		wdComponentAPI.getMessageManager().reportSuccess(str1);
		}

Any ideas why it cannot find the class?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

can u just try this code

String ps="select * from studentdata"
                                String userName = "sa";
				String password = "jktsql";
				String url ="jdbc:microsoft:sqlserver://<servername>:1433;databaseName=student";
				String querry="select * from empDetail where name=?";
				Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
				Connection con =DriverManager.getConnection(url, userName, password);
				Statement st=con.createStatement();
                                ResultSet rs=ps.executeQuery();
                                while(rs.next())
				{
                                 String strn=rs.getString(1);
             wdComponentAPI.getMessageManager().reportSuccess(strnj);
}

regards,

H.V.Swathi

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi,

i am also developing the application in which i will connect to sql database...

the step followed is ...

i have made a DSN in VA ....

then using these DSn i have write a method for geeting connection...

and this method i have just placed under util folder and using these method i am getting the connection....

it si working absoultely fine...

if u want a code u can reply me back....

Former Member
0 Kudos

I think its better to create a data source in Visual Admin.

create driver for SQL Server with the three jar files.

create a data source.

Add the Driver entry in Connector Container

vinod

Former Member
0 Kudos

Hi Lynton,

Note that the data-types used in SQL and those used in Web Dynpro for Java are different.

For example, the data-type used in SQL for a string field is varchar where as it is String in Java.

I used to get the same exception when I was trying to create an context attribute in Web Dynpro, value and type of which I got by querying the SQL server. Later on, when I changed the type from varchar to String, it actually worked!

I guess you are doing the same mistake.

Try the code given by Swathi. It should work fine.

Regards

Kishan

Edited by: kishan chandranna on Dec 23, 2008 6:35 AM

former_member211296
Participant
0 Kudos

Hi

Before deploying the ear file, you should check the WebDynpro reference. All the Jar files that you have added is available under the library project, that you can find in the visual administrator.

For example, Let us say all the three .jar files are available under the MSSQLDriver Library project. So, you have to add the MSSQLDriver in the WebDynpro Reference.

And then deploy.

If you are not finding the Library project in the Visual admin, you have to create a Library project with the above three Jar files, and then you have to deploy.

Here MSSQLDriver is the Library project Name.

Regards,

Prasath.

Edited by: Hariprasath Ramalingam on Dec 22, 2008 6:36 PM

former_member192434
Active Contributor
0 Kudos

Hi

Please refer to the SAP Note 639702. You need to SQL Server driver (jars) installed and in path.

Hope it will help you.

Thanks

Former Member
0 Kudos

I have the JAR files in the LIB folder of the Webdynpro application......and have added them to the "Java Build Path"....."add external JARS..."

Not sure why it is battling to reference the class.....any ideas?

Lynton

Former Member
0 Kudos

Hi Lynton:

Where did u added the JAR files?

Tnx,

MS