Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I'm doing a Java SWING application which has to access a database in MS SQLSERVER 2008.As its easy and I have done in MySQL,i tried the same method for this also.But it failed. So I tried some tutorials and ended up in a code in here...

Connecting to SQL Server 2008 from Java[^]

All the errors were cleared and still I'm not satisfied that,I'm getting a piece of comments in my console output area as

**# JRE version: 7.0_25-b17
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.25-b01 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# V [jvm.dll+0xf66dc]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\KaNNaN\Documents\NetBeansProjects\DBCollection\hs_err_pid4908.log
#
#If you would like to submit a bug report, please visit:
#http://bugreport.sun.com/bugreport/crash.jsp
#
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)**
Database name : master Connection String : Data Source=KANNAN-PC\SQLEXPRESS;Initial Catalog=master;Integrated Security=True Owner : sa

Help me to resolve this and connect to the SQLSERVER database or suggest me with some good tutorials.
Posted
Comments
[no name] 1-Aug-13 21:18pm    
Okay.... resolve what?
Suramanian Nampoothiri 1-Aug-13 21:52pm    
Please read the question before commenting....
[no name] 1-Aug-13 22:26pm    
I assure you I read your "problem" quite thoroughly. Maybe you should read it.
walterhevedeich 1-Aug-13 21:46pm    
You might want to check that error report file.
Suramanian Nampoothiri 1-Aug-13 21:53pm    
I checked....and the error is what i have given with # symbol

I have previously worked with the SQL Server 2008 Database Engine and have been able to connect to it using the JDBC Driver.

Download and extract the JDBC Driver for SQL Server from Microsoft's Downloads:
Windows Version[^]
Linux Version[^]

Once you have your Java Libraries, you can use them in your project to import the libraries.
The following is sample Connection String that you may adopt for connecting to the database.

Java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class SQLServer2008{
 private Connection transactSql() throws SQLException{
  Connection connection =
    DriverManager.getConnection(
      "jdbc:sqlserver://host_ip_address:port_number;databaseName=db_name", "username", "password");
  return connection;
 }
}



You can then call this method while declaring, initializing, and defining your database connnection. This worked for me, I hope it worked for me.

P.S. If this answer satisfies your need, please approve this answer by marking it as solved.
Thank you.
 
Share this answer
 
CAN YOU HELP ME GET MY JAVA45
 
Share this answer
 
Comments
Member 10345598 19-Oct-13 1:53am    
IM HAVING TROUBLE CONECTING TO JAVA IT SAYS IT IS DOWNLOADED BUT DOES NOT LET ME PLAY MY POGO GAMES

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900