Accessing Java Within SQL Server
Aug 21, 2007have a Java Class that I want to be able to access from within a SQL Server Stored procedure. I know we can access C# and other .NET Framework code, but how can you access a Java Class?
View 1 Replieshave a Java Class that I want to be able to access from within a SQL Server Stored procedure. I know we can access C# and other .NET Framework code, but how can you access a Java Class?
View 1 RepliesI have a Java Class that I want to be able to access from within a SQL Server Stored procedure. I know you can access C# and other .Net code, but can you also access a regular Java class this way?
View 1 Replies View RelatedHi,
Based on jax-ws 2.0 technology, I built a java client application to access a report via the web service interface of the SQL Server Reporting Services 2005.
I used the jax-ws "wsimport" tool to generate the java classes needed to call the web services (The class generation is based on the wsdl and I used this one http://serverName/reportserver/reportexecution2005.asmx?wsdl) and wrote the following sample code :
ReportExecutionService service = new ReportExecutionService();
ReportExecutionServiceSoap rs = service.getReportExecutionServiceSoap();
String reportPath = "HelloWorld";
String format = "MHTML";
String devInfo = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
Holder<byte[]> result = new Holder<byte[]>();
Holder<String> extension = new Holder<String>();
Holder<String> mimeType = new Holder<String>();
Holder<String> encoding = new Holder<String>();
Holder<ArrayOfWarning> warnings = new Holder<ArrayOfWarning>();
Holder<ArrayOfString> streamIDs = new Holder<ArrayOfString>();
try {
ExecutionInfo execInfo = rs.loadReport(reportPath, null);
rs.render(format, devInfo, result, extension, mimeType, encoding, warnings, streamIDs);
}
catch (Exception e) {
System.out.println( e );
}
The trouble is that an exception is caught on the call to the render method
javax.xml.ws.soap.SOAPFaultException: The session identifier is missing. A session identifier is required for this operation. ---> The session identifier is missing. A session identifier is required for this operation.
I found on the web (in C# examples) that this SessionId is supposed to be contained in the ExecutionId attribute of an
ExecutionHeader object. The ReportExecutionServiceSoap class (my rs object in the example) does not offer any way to directly set this SessionId or to associate an ExceptionHeader before calling the render method.
Have you ever tried - and managed - to do it.
Many thanks
Anyone have any tips for using Java against SQL Server? Our ITdirector is thinking of making us a Java shop, but I really would liketo stay with SQL Server as our RDBMS. We have Oracle Financials butour in-house development (currently VB6 client-server, soon to bereplaced by a service-oriented architecture based around Sonic andincluding SalesForce, both of which are Java) has been against SQLServer. He says five years ago at his old company Java/SQL Server hadlousy performance. I vaguely remember that since then Microsoft cameout with their own JDBC driver for SQL Server... Anyone have experiencewith this? Any performance tips will be hugely appreciated.TIA
View 10 Replies View RelatedWhat r the pros and conditions of using MSsql server ?
what the effect of data on the performance in case of MS SQL server?is it good enough tohandle data overloads?
how good the java ms sql server combo works in comparison to other databases !!
Hi,
I want to connect to sql server using java and want retrive data.
I am getting following exception:
[Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect. Invalid URL.
My url
String url = "jdbc:microsoft:sqlserver://servername:6013/databasename";
please let me know if any thing wrong in my url.
Thanks,
How to connect to the named instance of SQL Server using Java?
I had the following code working fine(but with the default instance only)
SET JAVA_HOME=D:Program FilesJavaSoftJRE1.3.1_03
"D:Program FilesJavaSoftJRE1.3.1_03injava" -classpath Launcher.jar;Sprinta2000.jar;log4j.jar;activation. jar;mail.jar Launcher -Ddatabase -Uuser -Ppassword -Sserver:1433 -hlocalhost -p9900 -TTrue -VFalse -QK -QS
But the same code is failing with the named instance:
SET JAVA_HOME=D:Program FilesJavaSoftJRE1.3.1_03
"D:Program FilesJavaSoftJRE1.3.1_03injava" -classpath Launcher.jar;Sprinta2000.jar;log4j.jar;activation. jar;mail.jar Launcher -Ddatabase -Uuser -Ppassword -Sserverinstance:1434 -hlocalhost -p9900 -TTrue -VFalse -QK -QS
I have a java compiled jar file, which accept the connection string as follows: -Uusername -Ppassword -Sservername:port
This string works fine with the default instance of SQL Server, I mean as long as you supply the name of the SQL Server as 'SQLServer', but if I want to run it against the named instance of SQL Server like 'SQLSERVERNamedInstance' then the connection is failing, giving me the unknown host error. Any idea why?
Greetings All, I would be much obliged if anyone can point me to agood book on Java/JDBC and SQL Server.Regards, Louis.
View 1 Replies View RelatedHi, Is there a special jdbc driver for SQL Server Compact Edition (2005) available? I'm getting error messages when trying to run java application on Pocket PC (Mobile 5.0):
java.lang.UnsatisfiedLinkError: java/sql/DriverManager.getCallerClassLoader()Ljava/lang/ClassLoader;
at java.sql.DriverManager.getConnection(Unknown Source)...
Mixxo
Hi, guys. It's the first time I connect a database.
My OS is windows XP.
I downloaded the sqljdbc on microsoft website and unzipped it.
Copy the sqljdbc_1.1 to the directory C:Program Files.
Modified the system variables:
classpath=.;%JAVA_HOME%libdt.jar;%JAVA_HOME%lib ools.jar;
%ProgramFiles%sqljdbc_1.1chssqljdbc.jar
JAVA_HOME=D:Program FilesJavajdk1.5.0_10
ProgramFiles=C:Program Files
I installed the sqlserver 2005and created a sqlserver db engine with windows authentification by default.
Using the management studio I created a database named BudgetAuthorization.
After that I created a user:
CREATE LOGIN aaron792 WITH PASSWORD='12345'
USE BudgetAuthorization
CREATE USER aaron792
Now I want to write a java application to access the database.
The application and the database are on the same computer.
I started the TCP/IP service, using the configuration manager.
Then use the eclipse to write the java application:
import java.sql.*;
public class TestJDBC
{
public static void main(String[] srg)
{
String driverName
= "com.microsoft.sqlserver.jdbc.SQLServerDriver"; // Start JDBC
String dbURL = "jdbcqlserver://localhost:1433;
DatabaseName=BudgetAuthorization"; // Connect the server and the database
//String userName = "Administrator"; // windows user
//String userPwd = "password"; // windows login password
String userName="aaron792";
String userPwd="12345";
Connection dbConn;
try
{
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL,userName,userPwd);
System.out.println("Connection Successful!");
// if successful print Connection Successful!
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
But it cann't be done!
The error information is:
Login failed for user 'aaron792'. The user is not associated with a trusted SQL Server connection.
I also tried the windows user, still failed.
What's wrong? Can anyone help?
Many thanks!
As in some of the databases stored procedures can be written in java. Java stored procedures run into inbuilt JVM of database.Does SQL server provides any support for writing stored procedures in java.Is there any inbuilt JVM in SQL server.
View 1 Replies View RelatedHello, Everybody.
Help me please with one problem which I'm facing with while deploying java server application on my computer (this java app is jBilling). I have configured it as it was said in docs, I have added environment variable CLASPATH as Microsoft documentation said. I'm using SQL Server JDBC driver 1.2 by Microsoft. The result is that I find this message in log file:
2007-05-27 17:21:41,906 WARN [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.microsoft.jdbc.sqlserver.SQLServerDriver; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: com.microsoft.jdbc.sqlserver.SQLServerDriver))
at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:168)
... and so on.
I have copied sqljdbc.jar to lib folder of the server. That's how I specified connection string:
jdbc:microsoftqlserver://localhost:1434;DatabaseName=Billing;integratedSecurity=false;
Can not think out what to do else. Maybe somebody knows what to do about it?
Many thanks
Hey All,
I am having a problem connecting to a database I have with a java app I am creating for my senior project. I am using the latest MS JDBC for connecting to the SQL Server.
Below is the code I am trying to run:
try {
ds.setIntegratedSecurity(true);
ds.setServerName("localhost\SQLEXPRESS");
ds.setDatabaseName("*databasename*");
con =ds.getConnection();
} catch (Exception ex) {
ex.printStackTrace();
}
The ds and con variables are declared and initialized correctly. The error I am getting now is this:
com.microsoft.sqlserver.jdbc.SQLServerException: Cannot open database "*databasename*" requested by the login. The login failed.
Any suggestions on what I could be doing wrong?
How to encrypt the java application code using the 'with encryption' clause from sql server stored procedure or function.
View 3 Replies View RelatedI've just started getting this EXCEPTION_ACCESS_VIOLATION (0xc0000005) on machines using Windows 2000 sp4 connecting to SQLServer. This is crashing JVMs (multiple Sun versions and BEA also) in the Java VM frame (outside our code). This has just started recently - perhaps with the last set of patches? Has anyone else seen this or know what I could do to get more information? Could this be related to updates to named pipes?
Thanks!
-Brian Temple
I'm having a problem connecting with a Java application but I CAN connect using my .Net application - the user name and password are the same for both (using the same database on SQL Server Express 2005).
The error I get is: "com.microsoft.sqlserver.jdbc.SQLServerException: Cannot open database "CORNERS" requested by the login. The login failed." An interesing note - I get the same message if the database is not running.
SQL Server Express 2005 is installed in mixed mode.
Here is my connection string in the .Net appplication: <add key="connectString" value="Server=(local);UID=sa;PWD=myPasswd;Database=CORNERS" />.
These are my values in my Java app web.xml -
<init-param>
<param-name>DBDriver</param-name>
<param-value>com.microsoft.sqlserver.jdbc.SQLServerDriver</param-value>
</init-param>
<init-param>
<param-name>DBURL</param-name> <param-value>jdbc:sqlserver://localhostsqlexpress:1055;databaseName=CORNERS</param-value>
</init-param>
<init-param>
<param-name>DBUser</param-name>
<param-value>sa</param-value>
</init-param>
<init-param>
<param-name>DBPwd</param-name>
<param-value>myPasswd</param-value>
</init-param>.
And yes, the port is 1055 - I checked to find it.
I am using Microsoft SQL Server 2005 JDBC Driver 1.0 (sqljdbc_1.0.809.102).
Does anyone have any idea what is wrong so that the login fails in the Java application but works in the .Net application?
Hi
I have created a linked server from SQL Server 2005 (SP 1) to SQL Service 2000 (SP 4) with a sql server login that is available on both servers but with different passwords and permissions.
I am getting the following error while accessing the linked server in management studio based on the scenario given below ;
------ Error Message Starts
OLE DB provider "SQLNCLI" for linked server "(SQL Server 2000 instance name)" returned message "Communication link failure".
Msg 10054, Level 16, State 1, Line 0
TCP Provider: An existing connection was forcibly closed by the remote host.
Msg 18456, Level 14, State 1, Line 0
Login failed for user 'abc'.
------ Error Message Ends
Consider login name is abc.
Now this login abc has sysadmin rights on sql server 2005.
The same login abc has only db_datareader rights on sql server 2000 on just one database and is not associated with any fixed server role.
I have configured the linked server using the following options;
1. I have tried impersonating login from SQL Server 2005 to SQL Server 2000 .
2. I have also tried specifying remote login / password option.
Anyone having any idea, would be of great help.
Regards,
Salman Shehbaz.
Hi
If my site is hosted with an external company web host can I use ASP.NET pages to connect to a MS SQL DB that is on my company's internal server if I had MS SQL installed on it?
My company's server is always on and always connected to the internet.
I have access to my company's server if I need to set anything up on it for this to happen.
There will not be any kind of overload as the site is not accessed constantly.
Also, would this cause any kind of security leak? If so how would I go about plugging this hole?
Our server does have confidential info on it.
Cheers
kefi2927
I'm using OLEDB in my ASP code to connect to the SQL database. When I execute the page I got an error saying "438, Microsoft VBScript runtime error, Object doesn't support this property or method"
Anybody knows what this is in reference to.
I tested the same site in another server where IIS and SQL are in the same box and it's working fine.
Thanks for any input in this......
I need to write a VB app (VB6) to access and manipulate data within a MS SQL Sever 2000 database. I have experience doing this with MS Access. Is it much different/more difficult to do this with SQL Server?
Thanks
What is the easiest way to start executing SQL statements onto a SQL Server 2000 using C++ ?????
Are there any libraries or something I could use ?
Greetings. I am curently having problems with authorizations while attempting to connect to SQL Server with an Asp.NET web application. I will try to explain my problem as clearly as possible.
I am developing an Asp.NET web application with Visual Studio to connect and view a database on a remote SQL Server. In my Web.config file, I have added the line
<identity impersonate = "true"/>
In my IIS security options, I have disabled the annonymous authentication and enabled the Windows mode authentication instead. When accessing the database from my computer, by compiling and debugging my web application in Visual Studio, everything works wonder. When I try to use the web application from a remote computer using the IP address or from my own computer using localhost in the URL, it asks me for my Windows username and password, which I provide, and then refuses any further access, saying I don't have permission to even connect to the server.
How can I go around this and allow my users to connect to the server from a remote computer? My machine is running Windows XP SP2 and the server is running Windows Server 2003.
Thank you in advance for any help you may provide,
Marie
Hi,
I am developing a windows application that needs to communicate with a remote SQL server 2005 database. Server allows remote connections and MSDTC service also running. Do I need to run MSDTC service on the client machine where I use desktop application ? any ideas ? It's throwing some error like
An error has occurred while establishing a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the fact
that under the default settings SQL Server does not allow remote connections.
But my SQL Server allows remote connection, and I am able to do a select statement.
But when I insert/update anything, it's throwing this error. I guess some problem with MSDCT. Anybody have any idea ?
Hi guys,
I need to know on how to connect MS SQL Server Database if I use Java (JCreator).
1. How to connect
2. How to use call stored procedures.
Many thanks.
My preferred programming language is Java (sorry Microsoft). I've searched for examples of running DMX queries into an Analysis Services database from Java but failed to locate any. I've seen suggestions that XMLA could be used but again, I can't locate any examples (in any language). For my current project I ran up the white flag and used C# instead but this wouldn't be an option in other cases. It would be possible to make the DMX calls from C# objects and call those from Java but that's pretty labourious to code.
Suggestions?
Hi everyone,
First of all I'd like to say I'm new to the forums, and in fact new to ASP.net.
I've had a couple of applications running in VB.net for the last year or so that I now am looking to move on and into ASP.net (main reason is to do with implementation to remote sites in foreign countries).
I'm currently following through the "Working with data and ASP.net 2.0" walkthrough on this site, which I must say has been a great help.
I'll start with the background stuff first
I have my main database on an SQL server. I also have 2 other databases on there - Customer and Employee. The reason for these are that they are shared amongst my VB applications and I kept them as seperate databases so that one database is all that needs to be administered and maintained, and these changes are then seen on both apps (takes away redundant data as well).
In my main database, main table, is a field called CustomerID. This value relates to the CustomerID in the Customer table. In my VB app all I do is have the user select a customer name, and then the customer ID value is copied to the CustomerID field of my main table when inserting / updating a row. This is simply accomplished with 2 SQL connections and 2 dataAdapters. I also use 2 dataSets - one for Customer, one for WorkRequests (the main database)...
I use ComponentOne stuff so that my grid will show the CustomerName instead of the CustomerID etc, and the same applies when I use my Employee database - I run many dataAdapters to this for things such as Account Manager, Technologist, Creator, UpdatedBy etc etc.
Now, I'm new to VS 2005 - my apps were created in VS 2003 and .net 1.1. Can I easily re-create my apps in ASP.net? My primary goal at the moment is to make sure I can load a row, and display the "lookup" values instead of the "integer" value. As my tables are in seperate databases, I would like to know the best way of accomplishing this, if it is of course possible.
Help and advice much appriciated.
Kind Regards,
Luke
Hi Everyone,
I just started using ASP.NET and I cannot figure out how to use a connection string to connect to a SQL Server database using ASP.NET. I want to use Windows Authentication to bring up a database called upsizedCandidate on a server called SQLSERVER and display a table within that database through internet explorer. I'm not sure if I should be using OLE DB or ODBC. Can anyone help me with this? Thanks in advance!
Hello all.
I am currently running a web server with Windows 2000 Server installed. It is a Pentium II 400 MHz, and also acts as the router on our network. I am worried that installing MSDE on this same server might drain the server resources, so I installed MSDE on one of the computers in our internal network. How do I set up my connection string to access the database on another machine in the same network?
Currently I use: Server="AnotherComputer";TrustedConnection="True";Database="MyDatabase"
When I use that, it tells me that the server can't be found. All computers behind the router have static IP addresses, but even when I type the IP address it still can't find the server. Any suggestions?
I have installed SQL Server on my laptop (full version), but can only access it while on the network. If I disconnect from the network, open Enterprise Manager, and click on my connection, I get the error "sql server does not exist or access denied". Why can't EM find my own machine? I even logged onto my own computer as a local user, instead of the network domain, and still recieved the error. Can someone tell me where I can edit (maybe my registration properties), so that I can run SQL server, while offline.
Thanks!
Trevor
How can I connect to SQL server on intranet using VB.NET??
I am unable to do that using system DSN.
can anyone tell how to do that either through DSN or anyother way.
hi,
I have MS Access Database (test.mdb), and i have a table called tblEmployee in that.
How to query the table from SQL Server Query Analyser?
Thanks in advance
qAnand
Hello All.
I need your advise on how I could access table from another server.
Let me explain what I am doing. Currently, I have 2 servers running parallel to one another other each loading from the same set of data into its own database in the night.
I would like to write a stored procedure to report the number of records from selected tables from the 2 servers to see if they match in records loaded. Thereafter, email me the results (I have already settle the sending of email part).
Have picked up some tips in this forum to come up with the below statements and it works fine for me: -
use AABBCC (database name)
select Server='Server 009', name, rows, SystemDate=getdate() from sysindexes
where name in ('invoice_line', 'invoice_line_import', 'sales_order_line', 'sales_delivery_line','Cust_dely_reliabity','sales _order_proc_time','AU1016','NZ_Data')
order by name
Result: -
Server Table Name Rows
Server 002AU1016 0
Server 002Cust_Dely_Reliabity 5017342
Server 002invoice_line 4397800
Server 002invoice_line_import 12120
Server 002NZ_Data 649745
Server 002Sales_Delivery_Line 5323875
Server 002Sales_Order_Line 5356989
Server 002Sales_order_proc_time 3651362
Instead of running the above scipt or stored procedure from 2 servers and received 2 email (one from server 002 & one from server 009), I would like to access the other server within the same stored procedure.
I have used sp_addlinkedserver (may not be the correct method) and <servername>.<databasename>.dbo.sysindexes (doesn't work)
Please help. Thanks a million.
The desired result could be:
Server 002 .....
Server 002 .....
.
.
Server 009 ..... (result from the 2nd server)
Server 009 .....
.
.
Best regards