|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Connecting Java with sql server
Hi
I am working on sql server 2000 , but i can not connect it with my java application. could any one help me in this regard. An simple example or demo , of how to connect sql database with java applet would be wonderful. Thank you |
|
#2
|
|||
|
|||
|
Ahmad,
It's not as hard as it sounds... I haven't interfaced Java w/ SQL server, but JDBC with any database server shouldn't be a tough task... Read Sun's tutorial on JDBC. HTH!
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#3
|
|||
|
|||
|
Que tal!
Encontre algo similar a lo que buscas en la siguiente direccion, espero te sea de gran utilidad. Articulo java-sql server Saludos!. Andres |
|
#4
|
|||
|
|||
|
This is fuction to Open a connection to SQL server (and Client) that I do completed! You can see it. Good luck to you!
----------------------------------------------------- private boolean openConnection(String strServerIPAddress, String strDatabaseName, String strUserName, String strPassword) { //String connect to SQL server String url = "jdbc:microsoft:sqlserver://" + strServerIPAddress + ":1433" + ";DatabaseName=" + strDatabaseName; try { //Loading the driver... Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" ); } catch( java.lang.ClassNotFoundException e ) { return false; } try { //Buiding a Connection m_Conn = DriverManager.getConnection(url, strUserName, strPassword); if(m_Conn == null ) return false; } catch( java.sql.SQLException e ) { switch( e.getErrorCode() ) { //... return false; } } return true; } |
|
#5
|
|||
|
|||
|
Jdbc
I've tried to connect to my SQL Server 2k (local) machine to no avail.
Even the source code from Sun doesn't work. I've used Microsoft's and Datadirect's JDBC driver. Everything compiles successfully but throws these errors at runtime: (Datadirect JDBC driver) ClassNotFoundException: com.ddtek.jdbc.sqlserver.SQLServerDriver SQLException: No suitable driver (Microsoft JDBC driver) ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver SQLException: No suitable driver This is the modified sample code from Sun Java website: import java.sql.*; import java.util.*; public class CreateNewTable { public static void main(String [] args) { String url = "jdbc:microsoft:sqlserver://(local):1433"; Connection con; Statement stmt; try { Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); } catch(java.lang.ClassNotFoundException e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); } try { con = DriverManager.getConnection(url); stmt = con.createStatement(); ... |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > Connecting Java with sql server |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|