For Windows 64 bit
Copy the path of sqljdbc4.jar i.e.
C:\Program Files\Microsoft JDBC Driver 4.0 for Server\sqljdbc_4.0\enu\
sqljdbc4.jar
Copy C:\Program Files\Microsoft JDBC
Driver 4.0 for Server\sqljdbc_4.0\enu\ au\(sth).jar to bin folder in java and
in system32.
Stop SQL 2005 Services and then:
Enable TCP/IP and then copy no. in
dynamic port from properties of TCP/IP
Establishing SQL
connection in Windows 32 bit
Control Panel à
Make the icons small à
choose “Administrator Tools” à
choose ODBC DataSource à
Choose SystemDSN tab à
click Add àMake SQL Native Client with:
Name – demo (name of the database
already created by user)
Server name – (name of the server)
(For server name:
Open
Microsoft SQL Server Management Studio Express
Under
File menu, click “Connect Object Explorer…” and copy the server name.)
Then, add login name i.e. “sa” and
password (used during installation of server)
Click Next
Change default database à
Choose database already created by user à
next à Finish à
OK à
OK
Now, make a file in notepad:
And run this in cmd.
And
we are DONE!!!!!!!
Java Frame for employee database
Need to import sql.* to use sql database
by:
import java.sql.*;
Class.forName is used for loading the
jdbc(or java) drivers.
DriverManager class is used for loading
the odbc drivers. It returns the value to Connection con.
Connection con =
DriverManager.getConnection("jdbc:odbc:demo","sa","qwerty");
//method with argument and returning object.
PreparedStatement class is used for
inserting, updating and deleting the data. It has 2 methods (actually many
methods):
1. executeUpdate()
2. executeQuery()
No comments:
Post a Comment