I just want install ODBC driver for doing JDBC.How I must configure while installing SQl 2005 Express?.Which authentication I have to provide ?Whether Windows or SQL authentication?I want to connect jdbc odbc driver to my own system itself.
Thank You in advance.
There is no need to use an ODBC-JDBC bridge with SQL Server. You can download the latest JDBC driver here http://www.microsoft.com/downloads/details.aspx?familyid=f914793a-6fb4-475f-9537-b8fcb776befd&displaylang=en
You can learn about the driver here http://msdn.microsoft.com/data/learning/jdbc/
Reference documentation is here http://msdn.microsoft.com/data/ref/jdbc/
|||
import java.sql.*;
public class AuthorsInfo
{
public static void main(String args[])
{
try
{
String str="SELECT * FROM sudheer";
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
/*Establish a connection with a data source*/
Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost;user=MyUserName;password=*****");
/*Create a Statement object to process the SELECT statement*/
Statement stmt=con.createStatement();
/*Execute the SELECT SQL statement*/
ResultSet rs=stmt.executeQuery(str);
while (rs.next())
{
System.out.println(rs.getString(1)+rs.getString(2)+rs.getString(3));
}
con.close();
}
catch(Exception ex)
{
System.out.println("Error occurred");
System.out.println("Error:"+ex);
}
}
}
I wrote the code and it is giving no class found error.Where to set the class path CLASSPATH =.;C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.1\enu\sqljdbc.jar?
How can I keep userid and password?
Thank You
No comments:
Post a Comment