CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 Connecting MSSQL server from a simple java class

Print topic Send  topic

Author Message
mano

Posts: 2
Posted: 04/11/2005, 9:25 PM

HI,
I have a problem with JDBC , where i want to connect to a MSSQL Server 2000 Database stored in my local computer via a simple java class.And i have the required driver too but have a problem how to do it, Here's the code i use and this gives the following error message...


F:\j2sdk1.4.2_01\bin>javac Db.java

F:\j2sdk1.4.2_01\bin>java Db
Exception in thread "main" java.lang.NoClassDefFoundError: Db


I have already set the classpath to all the three jar files of the driver but this was the result! pls help me.. if there's any tutorials for this matter pls send the link too.



import java.sql.*;

public class Db {
public static void main(String[] args) {
try {



Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");

Connection connection = DriverManager.getConnection("jdbc:odbc:MyDB");
if (connection != null) {
System.out.println();
System.out.println("Successfully connected");
System.out.println();
//String dbUrl = "jdbc:odbc:MyDB";

}


}catch(ClassNotFoundException e)
{System.err.println(e);}
catch (SQLException t)
{
System.err.println(t);}
}
}



when i use the code
"
DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());"

to get the connection it gave ....


F:\j2sdk1.4.2_01\bin>javac Db.java
Db.java:7: package com.microsoft.jdbc.sqlserver does not exist
DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerD
river());
^
1 error
_________________
Nothing without effort!
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.