Java program to watch sql server for new data

I need to write a java program to watch a ms sql server database table, whenever there are data inserted into this table, I need to followup with some functions!
I have done some jsp work before, but writing a java process that would do watch, i have no idea. any help?
thankx
ku

The only efficient mechanism I can imagine would be to define a trigger on insert and/or update on the table and have this do something (not sure what, don't use MS SQL Server these days).
Chuck

Similar Messages

  • Can I call a Java program from a SQL Server Trigger?

    Hello,
    I want to encrypt some data in a database column in SQL Server. Today I am using java code to encrypt the value and store it in the database using JDBC.
    Now I want to use a VB client to store the encrypted value in the SQL Server DB. Since the encryption is handled by a java class, can I write a trigger in SQL Server that while inserting the raw data, calls the java class for encrypting the value and then inserts the encrypted value into the column?
    In general, is it possible to call a java class from a SQL Server trigger?
    Thanks
    Bipin

    Here are 3 examples of code for insert, update and delete:
    CREATE TRIGGER [PLI_INSERT_TRIGGER] ON [dbo].[PLI]
    FOR INSERT
    AS
    Declare @cmd sysname, @code sysname, @list sysname
         Select @code = PLI_K_COD, @list = PLI_K_LISTINO from inserted
         Set @cmd = 'java mirrorDb.Copy PLI INSERT ' + @code + ' ' + @list
         EXEC master..xp_cmdshell @cmd
    CREATE TRIGGER [PLI_UPDATE_TRIGGER] ON [dbo].[PLI]
    FOR UPDATE
    AS
    Declare @cmd sysname, @code sysname, @list sysname
         Select @code = PLI_K_COD, @list = PLI_K_LISTINO from inserted
         Set @cmd = 'java mirrorDb.Copy PLI UPDATE ' + @code + ' ' + @list
         EXEC master..xp_cmdshell @cmd
    CREATE TRIGGER [PLI_DELETE_TRIGGER] ON [dbo].[PLI]
    FOR DELETE
    AS
    Declare @cmd sysname, @code sysname, @list sysname
         Select @code = PLI_K_COD, @list = PLI_K_LISTINO from deleted
         Set @cmd = 'java mirrorDb.Copy PLI DELETE ' + @code + ' ' + @list
         EXEC master..xp_cmdshell @cmd
    you must go "sql server entreprise manager" right click on the table you want to add triggers and select: all activities, manage triggers.
    You have 3 examples: for an insert, for an update and for a delete
    ON [dbo].[PLI] specify the table on which you want to setup trigger.
    FOR DELETE, INSERT, UPDATE specify the event.
    The Declare statement create the variables in which I want to put some values to pass to the java program, for example which table, which event, which key fields.
    the "Select @code = PLI_K_COD, @list = PLI_K_LISTINO from inserted" set the variables with the value of the columns of the table I am interested to read from my java program, for example the variable @code receive the value of the column pli_k_kod (is the key) of the table PLI.
    The "Set @cmd = 'java mirrorDb.Copy PLI DELETE ' + @code + ' ' + @list " prepared the variable @cmd with the java command followed by the package.classname and parameters.
    The EXEC launch the command to the operating system.
    Daniele

  • Tempdb in a subdirectory of \Program Files\Microsoft SQL Server\

    Hi,
    SAP ERP 6.0 / Sol. Man. 4.0 Installation Guide say "after initial installation of the database software, the <b>tempdb</b> is located in a subdirectory of <b>\Program Files\Microsoft SQL Server</b>. However later, when SAPinst builds and loads the database, it is transferred to a new <b>\TEMPDB</b> directory and extended to a size of 300 MB."
    I finished the installation some days ago but I still see file tempdb.mdf & templog.ldf in
    C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\
    May I delete these files because tempdb DB currently use the 2 files in <b>\TEMPDB directory</b>?
    Regards,
    Toan Do

    HI,
    <b>Moving the tempdb database</b>
    As the tempdb database is constantly being used by the SQL Server, it cannot be moved using the same process described above (sp_detach_db, sp_attach_db). Instead, you must use the 'alter database modify file' command.
    a) First display all tempdb database files using the following command:
    select convert(char(20),name) as name, filename from tempdb..sysfiles
    name      filename
    tempdev    d:\TEMPDB\TEMPDB.MDF
    templog    d:\TEMPDB\TEMPLOG.LDF
    (2 row(s) affected)
    b) Set a new storage location for the files by executing an ALTER DATABASE for each file:
    Example:
    alter database tempdb
          modify file (name=tempdev,filename='E:\NEW\tempdb.mdf')
    alter database tempdb
          modify file (name=templog,filename='E:\NEW\templog.ldf')
    c) Restart your SQL Server. The tempdb database is created again during each restart of the SQL Server. In this case, the files are now created in the new directory.
    <b>d) Use the NT Explorer to delete the old database files for the tempdb.</b>
    e) We recommend that you make a full backup of the master database after the change.
    <b>Refrence SAP Note:</b>
    Note 363018 - File management with SQL Server.
    Award points if helpful.
    Thanks,
    Tanuj

  • Unable to open the physical file "D:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\abc.mdf". Operating system error 2: "2(The system cannot find the file specified.)".

    hi,
    am running the below command for moving sql serevr mdf and ldf files  from one  drive to another : c  drive to d drive:
    but am getting the below error
    SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\abc.mdf". Operating system error 2: "2(The system cannot find the file specified.)".
    use master
    DECLARE @DBName nvarchar(50)
    SET @DBName = 'CMP_143'
    DECLARE @RC int
    EXEC @RC = sp_detach_db @DBName
    DECLARE @NewPath nvarchar(1000)
    --SET @NewPath = 'E:\Data\Microsoft SQL Server\Data\';
    SET @NewPath = 'D:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\';
    DECLARE @OldPath nvarchar(1000)
    SET @OldPath = 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\';
    DECLARE @DBFileName nvarchar(100)
    SET @DBFileName = @DBName + '.mdf';
    DECLARE @LogFileName nvarchar(100)
    SET @LogFileName = @DBName + '_log.ldf';
    DECLARE @SRCData nvarchar(1000)
    SET @SRCData = @OldPath + @DBFileName;
    DECLARE @SRCLog nvarchar(1000)
    SET @SRCLog = @OldPath + @LogFileName;
    DECLARE @DESTData nvarchar(1000)
    SET @DESTData = @NewPath + @DBFileName;
    DECLARE @DESTLog nvarchar(1000)
    SET @DESTLog = @NewPath + @LogFileName;
    DECLARE @FILEPATH nvarchar(1000);
    DECLARE @LOGPATH nvarchar(1000);
    SET @FILEPATH = N'xcopy /Y "' + @SRCData + N'" "' + @NewPath + '"';
    SET @LOGPATH = N'xcopy /Y "' + @SRCLog + N'" "' + @NewPath + '"';
    exec xp_cmdshell @FILEPATH;
    exec xp_cmdshell @LOGPATH;
    EXEC @RC = sp_attach_db @DBName, @DESTData, @DESTLog
    go
    can anyone pls help how to set the db offline. currently  i  stopped the sql server services from services.msc and started the  sql server agent.
    should i stop both services for moving from one drive to another?
    note: I tried teh below solution but this didint work:
    ALTER DATABASE <DBName> SET OFFLINE WITH ROLLBACK IMMEDIATE
    Update:
    now am getting the message :
    Msg 15010, Level 16, State 1, Procedure sp_detach_db, Line 40
    The database 'CMP_143' does not exist. Supply a valid database name. To see available databases, use sys.databases.
    (3 row(s) affected)
    (3 row(s) affected)
    Msg 5120, Level 16, State 101, Line 1
    Unable to open the physical file "D:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\CMP_143.mdf". Operating system error 2: "2(The system cannot find the file specified.)".

    First you should have checked the database mdf/ldf name and location by using the command
    Use CMP_143
    Go
    Sp_helpfile
    Looks like your database CMP_143 was successfully detached but mdf/ldf location or name was different that is why it did not get copied to target location.
    Database is already detached that’s why db offline failed
    Msg 15010, Level 16, State 1, Procedure sp_detach_db, Line 40
    The database 'CMP_143' does not exist. Supply a valid database name. To see available databases, use sys.databases.
    EXEC @RC = sp_attach_db @DBName, @DESTData, @DESTLog
    Attached step is failing as there is no mdf file
    Msg 5120, Level 16, State 101, Line 1
    Unable to open the physical file "D:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\CMP_143.mdf". Operating system error 2: "2(The system cannot find the file specified.)"
    Solution:
    Search for the physical files(mdf/ldf) in the OS and copy to target location and the re-run sp_attach_db with right location and name of mdf/ldf.

  • The distribution agent failed to create temporary files in 'C:\Program Files\Microsoft SQL Server\110\COM' directory. System returned errorcode 5.

    One of my replication job failed with below error, which means job failed because of permission issue on the folder. To resolve that, I have granted the permission and it started working fine. Now the question is as my job was running fine since long time
    without any issue then how suddenly the permission of the folder got omitted automatically? I am sure that no one deleted the permission from the folder and as the server is part of SQL cluster no failover occurs.
    Error:-The distribution agent failed to create temporary files in 'C:\Program Files\Microsoft SQL Server\110\COM' directory. System returned errorcode 5.
    Rahul

    Hi Rahul,
    Error code 5 indicates that the error is "access is denied."  Please make sure that the COM folder is excluded from any antivirus scan that occurs on the system.
    If the issue still persists, I recommend you use
    Process Monitor to find out a bit more about the accounts and access requests involved. Then grant write permission to the exact COM folder for the account that is running the SQL Server Agent service. For more details, please review the following similar
    thread.
    http://www.sqlservercentral.com/Forums/Topic1364832-1550-1.aspx
    Thanks,
    Lydia Zhang
    If you have any feedback on our support, please click
    here.

  • Need Guide to create a table in SQL Server and Process data for JDBC

    Dear All,
    Scenario:JDBC to JDBC
    I need to practice JDBC to JDBC scenario and for that i need to create a table in SQL server for sender ,receiver and update  i have installed SQL Server and no idea about creation of table and Connection string for PI.
    I want you to explain each and every step for the Table Creation ,Driver and connection string.
    Thanks in Advance.

    Try searchin in the forum and then google. This forum is not for teaching the basics.
    VJ

  • Can't figure out how to install sql server for PHP

    I am trying to install SQL Server for PHP on a server with Server 2008 32 bit.  The exe from http://www.microsoft.com/en-us/download/details.aspx?id=20098 keeps tell me that it is an invalid win32 application.  I've tried running as administrator
    as well.  Somewhere I read you need to open the exe with 7zip.  I was able to do that and see all the files in there, but where do I go from there?
    Thanks
    Mike
    edit: forgot to mention I'm using Apache for my server

    That solution is obsolete. The current solution is here:
    http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx
    bill ross

  • How to run a java program in windows 2003 server from unix server.

    Hi ,
    I want to run a java program in windows 2003 server from unix machine ..
    will RMI helps me to obtain this.
    Please tell me the procedure to do this.
    Thanks in advance,

    rmi,web services,corba,web 2.0,xml,xls,dtd,rss,ruby on rails,https,soap,tags,blog,podcast,google

  • Upgrade OM 2012 to SP1 Beta - Version of SQL Server for the Operational Database and the Data Warehouse

    Hello,
    When I try to verify the prerequisites to upgrade my SCOM 2012 UR2 Platform to SP1 Beta, I have these errors :
    The installed version of SQL Server is not supported for the operational database.
    The installed version of SQL Server is not supported for the data warehouse.
    But when I execute this query Select @@version on my MSSQL Instance, the result is :
    Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64)   Jun 17 2011 00:54:03   Copyright (c) Microsoft Corporation  Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7600: ) (Hypervisor) 
    But
    here, we can see that :
    Microsoft SQL Server: SQL Server SQL 2008 R2 SP1, SQL Server 2008 R2 SP2, SQL Server 2012, SQL Server 2012 SP1, are supported.
    Do I need to pach my MSSQL Server with a specific cumulative update package ?
    Thanks.

    These are the requirements for your SQL:
    SQL Server 2008 and SQL Server 2012 are available in both Standard and Enterprise editions. Operations Manager will function with both editions.
    Operations Manager does not support hosting its databases or SQL Server Reporting Services on a 32-bit edition of SQL Server.
    Using a different version of SQL Server for different Operations Manager features is not supported. The same version should be used for all features.
    SQL Server collation settings for all databases must be one of the following: SQL_Latin1_General_CP1_CI_AS, French_CI_AS, Cyrillic_General_CI_AS, Chinese_PRC_CI_AS, Japanese_CI_AS, Traditional_Spanish_CI_AS, or Latin1_General_CI_AS.  No other collation
    settings are supported.
    The SQL Server Agent service must be started, and the startup type must be set to automatic.
    Side-by-side installation of System Center Operations Manager 2007 R2 reporting and System Center 2012 Service Pack 1 (SP1), Operations Manager reporting on the same server is not supported.
    The db_owner role for the operational database must be a domain account. If you set the SQL Server Authentication to Mixed mode, and then try to add a local SQL Server login on the operational database, the Data Access service will not be able to start.
    For information about how to resolve the issue, see
    System Center Data Access Service Start Up Failure Due to SQL Configuration Change
    If you plan to use the Network Monitoring features of System Center 2012 – Operations Manager, you should move the tempdb database to a separate disk that has multiple spindles. For more information, see
    tempdb Database.
    http://technet.microsoft.com/en-us/library/jj656654.aspx#BKMK_RBF_OperationsDatabase
    Check the SQL server agent service and see whether it is set to automatic AND started. This got me confused at my first SP1 install as well. This is not done by default...
    It's doing common things uncommonly well that brings succes.

  • SQL Server 2012 Change Data Capture for Oracle by Attunity support for Oracle 12

    I would like to know if there are any plans for SQL Server 2012 Change Data Capture for Oracle by Attunity to support versions of Oracle 12 and if by when.

    I have asked from the author of
    http://blogs.msdn.com/b/mattm/archive/2012/03/26/cdc-for-oracle-in-sql-server-2012.aspx about this.
    I will either ask him to answer here or I would be a messenger.
    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • Is it possible to have access a table of DB SQL Server for the DB Oracle?

    Is it possible to have access a table of DB SQL Server for the DB Oracle? How?
    Thank you, Paulo.

    You can configure Heterogeneous Distributed Database Systems

  • Setting up SQL Server for LiveCycle ES2

    I have few queries regarding the installation please help.
    I am trying to install livecycle ES2 in Windows 7 system,Weblogic 11g,Sql server 2005 Dev Sp3
    1. In the installation guide under the section setting up sql server for Livecycle ES2 the below point mentioned .
    Select the Memory page and enter a size in the Minimum Server Memory (in MB) box that is equal to
    the size of the free memory on the server.
    How to find the free memory on the server ??
    http://help.adobe.com/en_US/livecycle/9.0/prepareinstallsingle.pdf
    2. Is It required to create LiveCycle ES2 database user, schema, and login in Sqlserver 2005 ? this step is not mentioned as optional why its required to create this stuffs ?
    3. While installing the Live Cycle Server when the installer prompts for a database configuration popup which db i should point to is it the db created for Livecycle or it should be the db from which i want fetch the data?
    4. In case if i am connecting to my application db (the place where my app data presents) where do i link the Livecycle db created with the Livecycle Server configuration?

    Hi,
    Do you have solution for this yet?
    I have same issue.
    Thanks
    YogLC

  • Best size for VM SQL Server for a start or maybe Azure SQL Database?

    Hello Everyone,
    My question is quite general but some of You may have already considered similar issues. Let's say or assume I have the website and mobile application - social kind - used by:
    1. 10 K users
    2. 100 K users
    3. 1 K K users
    4. 20 K K users MAX
    I am strongly considering use of VM SQL Server mostly because of its PARTITIONING functionality, some advantages in the context of INDEXING compared to Azure SQL Database and JOBs availibility.
    Question: what would be the best size and count of VMs related to SQL Server for the start and later?
    Question 2 - I am able to move JOBs functionality to my Worker role if I wanted to consider use of Azure SQL Database. SQL Server still has at least those 2 advantages (Partitioning, better Indexing) - is it worth considering Azure SQL Database service for
    100 K users and more?
    Regards,

    Hello Jambor,
    Considering the number of users i wouldnt recommend an Azure SQL database, because of certain limitations like Max worker threads, Max sessions, etc. Also the maximum size of the database can be 500GB.
    Please refer http://msdn.microsoft.com/en-us/library/azure/dn741336.aspx and http://msdn.microsoft.com/en-us/library/azure/dn369873.aspx for the Azure SQL database options and limitations.
    If your application needs to scale-out, Azure SQL Databases are recommended. If it needs scaling-up - then the choice is SQL Server on Azure VM. Please refer http://azure.microsoft.com/blog/2012/06/26/data-series-sql-server-in-windows-azure-virtual-machine-vs-sql-database/
    and http://azure.microsoft.com/en-us/documentation/articles/data-management-azure-sql-database-and-sql-server-iaas/ for comparison.
    If you already have your application running successfully on your on-premise server, you could use a similar machine on Azure for hosting your SQL server instance. The options are at http://azure.microsoft.com/en-us/pricing/details/virtual-machines/. You could
    start with a SQL Server enterprise edition on an A3 VM and then scale-up as needed.
    Regards,
    Kumar Bijayanta

  • Calling java program from PL/SQL code

    Dear,
    How to develop and call a java program from PL/SQL code?
    What about if this program will call other java programs?

    Perhaps the Java Developer's Guide would be a good place to start
    http://download.oracle.com/docs/cd/B19306_01/java.102/b14187/toc.htm
    Justin

  • ERR:10003 Unexpected data store file exists for new data store

    Our TimesTen application crashes and then it can not connect TimesTen datastore, and then we use ttIsql and get error "10003 Unexpected data store file exists for new data store".So we must rebuild the DataStore.
    I guess the application damages the datastore because we use "direct-linked" mode. Is it true?
    Should I use "Client-Server" mode if our data is very important?
    thx!

    Your question raises several important discussion points:
    It is possible (though very unlikely in practice) for a C or C++ program operating in direct mode to damage the contents of the datastore e.g. by writing through an invalid memory pointer. In the 11+ years that TimesTen has existed as a commercial product we have so far never seen any support case where this was diagnosed as the cause of a problem. However, it is definitely a theoretical possibility and rigorous program testing and use of tools such as Purify is strongly recommended when developing in C or C++ in direct mode. Java programs running in direct mode are completely 'safe' unless they invoke non-Java code via JNI when a similar risk is present.
    The reality is that most customers who use TimesTen in very high performance mission critical applications use mainly direct mode...
    Note also that an application crashing should not cause any damage or corruption to a datastore, even if it is using direct mode, as Times%Ten contains explicit mechanisms to guard against this.
    Your specific problem (error 10003) is nothing to do with the datastore being damaged. This error reflects a discrepancy between the instance main daemon's metedata about all the datastores that it is managing and the reality. This error occurs when the main daemon does not know about a datastore and yet when it comes to connect to (and hence create) the datastore it finds that checkpoint or log files already exist. The main daemon's metadata is managed solely by the main daemon and is completely separate from the datastore and datastore files (the default location is <tt_instance_install_directory>/info, though you can change this at install time). The ususal cause of this is that someone has been manually manipulating files within that directory (which of course you should never do) and has removed or renamed the .DBI file corresponding to the datastore.
    This error should never arise under normal circumstances and certainly not just because some application has crashed.
    Rather than simply switching to the (much slower) client/server mode I think we should try and understand why this error is occurring. Could you please post the following:
    1. Output of ttVersion command
    and then we can take it from there.
    Thanks, Chris

Maybe you are looking for

  • Error while doing cloning using Duplicate command

    Hi, I am facing issue while doing clonning using duplicate command 'Active database' The error i am facing is as follows. RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS

  • Where is the file that keeps track of which mail items were open?

    Searching for the file that keeps track of which mail items were open- sometimes it suddenly is shorter, forgets some of the items of mail that was open, in my 'in box' as it were. just happened to me- 15 emails I wanted to keep open till I answered

  • Help trying to list measures from cube.

    Hi all, I'm trying to list measures from a cube using BAPI_MDPROVIDER_GET_MEASURES, but the name of the measures (MES_NAM) I get seems to be coded, and I haven't been able to find how to convert it to "the usual" name. I must note that I don't know m

  • Prevent a rs232 crash when "operation completed succesfully"

    Dear all, A certain test set-up should run for long times (months) and makes good use of RS232 comunication (over USB). Data rates are not high, but frequent, to four different devices. Very occasionally the application crashes (in debug mode, runnin

  • Iphone 3G is out of maintenance and evolution? I saw no update aftere iOS 4.2.1

    It's a period when I connect to Itunes, anything happens, no news on IOS or similar. Checking in the Apple Site, I saw new iOS4.3.3 is only for 4g and 3gs ... how about 3G? It's out of stock? Same for iOS 5. Thanks Nikola