i have an sql file of the following form:
CREATE VIEW dbo.SomeView
AS select * from SomeTable
GO
ALTER TABLE [SomeTable] ADD CONSTRAINT [...] PRIMARY KEY CLUSTERED ([..],[TIME_STAMP],[..])
GO
and so on.. it contains only update queries.
i want to run it on an sql server that is situated on a remote machine. I’m using java and i read it is not possible to execute a file through jdbc.
i read this related post:
How to execute sql-script file in java?
my question is, how can i execute that file if the server is on a remote machine and not on my machine (i don’t have mssql server installed on my machine)?
P.S it would be nice to know if there is a solution to this problem in other languages (just a reference will do)
EDIT: the file is on the local machine.
thank ppl!
Do you have developer access to the remote machine? I.e., can you open ports?
You can use a simple socket and a remote shell to execute the queries (both sides can be Java but anything else will do).
If you have no administrative privileges, you might use some SSH API to login and execute a script.
If you have installed the SQL tools on your machine, you can still run them on the remote (if it is enabled and there are no firewall restrictions, for instance, but some additional configuration might be necessary). With MySQL, you may use something like this:
You can even do this from Java with the script you linked.