Showing posts with label Microsoft SQL Server 2005. Show all posts
Showing posts with label Microsoft SQL Server 2005. Show all posts

How can connect sql server 2005 with java in java?

In order to connect MySQL database with Java one need to use below mentioned sample script:

<%@ page import="java.sql.*" %>
<%@ page import="com.mysql.jdbc.Driver" %>

<%!
Class.forName("com.mysql.jdbc.Driver").newInstance ();
java.sql.Connection conn;
conn = DriverManager.getConnection(
"jdbc:mysql:///?user=&password=") ;
%>
Use the JDBC functionality to open a connection to SQL Server.
You can read up on how here:

What is the difference between oracle,sql and sql server?

Difference between oracle,sql and sql server
===================================

Oracle is based on RDBMS.
SQL is Structured Query Language.
SQL Server is another tool for RDBMS provided by MicroSoft.

My SQL Server Programming-Kill Spid?

Here's a little snippet from an SP i wrote a couple of years ago when i wanted to drop a db. Given the id of the database (@DR_ID), killed my processes just fine...
Get the dbid using the db_id() function.

    -- Get a cursor with the processes that have to die in order to be able to drop db
    DECLARE curProcesses CURSOR
        LOCAL
        FAST_FORWARD
        READ_ONLY
    FOR
        SELECT spid
        FROM
            Master..sysprocesses
        WHERE
            dbid = @nDR_ID

    OPEN curProcesses

    FETCH NEXT FROM curProcesses INTO --Gets the first process
        @nKillProcess
    SET @nFetchStatus = @@FETCH_STATUS

    --Kill the processes
    WHILE @nFetchStatus = 0
    BEGIN
        SET @sTemp ='KILL ' + CAST(@nKillProcess as varchar(5))
        EXEC(@sTemp)
        FETCH NEXT FROM curProcesses INTO --Gets the next process
            @nKillProcess
        SET @nFetchStatus = @@FETCH_STATUS
    END
    CLOSE curProcesses
    DEALLOCATE curProcesses

How to Kill All Processes That Have Open Connection in a SQL

The below code block can be used to kill all the processes which are connected to the database named @dbname except the process that the code block is running in the scope of. You can also set the database name by the DB_NAME() property.

DECLARE @dbname nvarchar(50)
DECLARE @SPId int

SET @
dbname = N'Works'
--SET @
dbname = DB_NAME()
DECLARE my_cursor CURSOR FAST_FORWARD FOR
SELECT SPId FROM MASTER..SysProcesses
WHERE DBId = DB_ID(@DatabaseName) AND SPId <> @@SPId

OPEN my_cursor

FETCH NEXT FROM my_cursor INTO @SPId

WHILE @@FETCH_STATUS = 0
BEGIN
KILL @SPId

FETCH NEXT FROM my_cursor INTO @SPId
END

CLOSE my_cursor
DEALLOCATE my_cursor

MySQL 5.0 vs. Microsoft SQL Server 2005

Database engines are a crucial fixture for businesses today. There is no shortage of both commercial and open source database engines to choose from. Microsoft SQL Server 2005 is Microsoft’s next-generation data management solution that claims to deliver secure and scalable applications while making them easy to deploy and manage. MySQL has long been the DBMS of choice in the open source community. The recent release of MySQL 5.0 has seen major changes in both features and performance to bring the database system into enterprise-level standards.

This paper aims to give the low-down on features most desirable to database developers and compare both database management systems in light of these features.

View Complete article here