on 12-22-2008 11:30 AM
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lynton:
Where did u added the JAR files?
Tnx,
MS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.