Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Java Help

Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-24-2007, 05:55 PM
mkcit mkcit is offline
Newbie
 
Join Date: Mar 2007
Posts: 2
Rep Power: 0
mkcit is on a distinguished road
Default connection between JAVA & SQL SERVER

Please members , i need to help me ..

now i'm establishing my graduate project, and i'm useing java programming language,and sql server to implement the application, but i face problem, that i don't know how i can connect java with sql server.

so i hope from you to help me please, and if possible explain that step by step, and support that by simple pictures, becuase these steps is very necessary for me.
note : i download JDBC driver from microsoft web site for connection, and attempt by simple tests to make connection but i failed.

THANKS FOREVER

Last edited by mkcit; 03-24-2007 at 06:00 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 03-25-2007, 04:35 AM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,470
Last Blog:
Joomla! And Incompeten...
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

This is the code for connecting to a mysql server that I made for another post

Code:
package net.codecall.forums.general;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class MySqlConnect {

	public static void main(String args[]) {
		Connection con = null;
		String dbname = "";
		String dbuname = "";
		String dbpassword = "";

		try {
			Class.forName("com.mysql.jdbc.Driver").newInstance();
			con = DriverManager.getConnection("jdbc:mysql:///" + dbname, dbuname, dbpassword);

			if(!con.isClosed()){
				System.out.println("Successfully connected to " + dbname);
			}
		} catch(Exception e) {
			System.err.println("Exception: " + e.getMessage());
		} finally {
			try {
				if(con != null){
					con.close();
				}
			} catch(SQLException e) {}
		}
	}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-25-2007, 06:24 AM
mkcit mkcit is offline
Newbie
 
Join Date: Mar 2007
Posts: 2
Rep Power: 0
mkcit is on a distinguished road
Default

Thanks Mr Sidewinder for code, but in fact i want the way to connect by sql server.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I centralize sql server database hoser2001 Database & Database Programming 3 07-13-2007 02:07 PM
Accessing Databases without SQL Server or FP Extensions ashleysmithd Database & Database Programming 2 07-10-2007 02:47 PM
Executing SQL Server 2k DTS Package via Visual Basic Joemama Visual Basic Programming 0 04-09-2007 07:21 PM
Database Tuning Advisor in SQL Server 2005 reachpradeep Database & Database Programming 0 03-03-2007 01:46 PM
Installing SQL server on Windows XP 64 bit roger Database & Database Programming 1 05-23-2006 11:13 AM


All times are GMT -5. The time now is 11:30 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads