How do I query SQL Browser Service from Java? - java

This might be a basic question, but I tried googling it and couldn't find an answer.
I need to make a list of all the SQL Servers on a network. This is very easy to do using the .NET framework (System.Data.Sql.SqlDataSourceEnumerator), but is there also a relatively simple way to do this in java as well? While I was doing my research, I came across the possibility of listening in at different ports, but that seemed un-user friendly.
I've been told to use SQL Browser Service, but a) I couldn't find any information on how to call that from java, and b) does this service get automatically downloaded when you download SQL Server? Can I assume that every computer on the network I'm searching has access to this browser service? And if not, does that make a difference to my code?
Thank you all so much.

You can use SQLBrowseConnect function from ODBC API.

You can call COM components from java (with suitably crafted IDL), so you could use DMO or SMO (depending on your SQL Server version)

I ended up using the command line's osql -L command to list all the servers on the network.

I have found it pretty easy to find all SQL services (assuming appropriate level of perms) by enumerating the Windows services on servers using WMI. This "catches" different SQL Server suite- services like Reporting Services and Analysis Services that are not the relational engine, plus services that are not running at the moment. I use this for license auditing, via PowerShell. So, if that seems useful, it's a matter of how to call WMI from Java. This dude: http://www.vijaykandy.com/archives/121 made a list of some options.

Related

Creating universal distribution group in exchange through Java

I need to create universal distribution groups in exchange server 2010 programmatically through Java. I tried to look but most API's are mail box specific and create groups within the mailbox. Or I have to use Power shell cmdlets. I am wondering if there is any possible solutions for Java or do i have to use .NET?
As far as I know, all Exchange administration is done through PowerShell now. Even when programming in .NET, you need to run PowerShell cmdlets to do anything with Exchange. I had to do that when I wrote a service in C# to create mailboxes for new users (we're running 2010 as well).
So if you want to do this, you'll need to run PowerShell with Java.
This might help (I have no experience with it; I just found it in a Google search): https://github.com/profesorfalken/jPowerShell
To really make things a pain, to get the Exchange PowerShell module installed, you have to install the Exchange management tools, which is part of the Exchange installation (you only select the management tools in the setup). You'll have to do that on any machine your app will run on.

Embedded Web Server

We currently have a web application which should be accessible from multiple sub-domains and from multiple actual domains. E.g. clients sign up and if they want to they can use their own domains. As far as I know this would be achieved by them pointing that domains A record at us and then our web server, which would have to be embedded so we can update at run-time, adding a virtual host dynamically.
Our web application is written in PHP (although playing around with HipHop to convert to C++) with static HTML and CSS. This web application communicates with a back-end Java API that uses the Restlet framework.
Does anyone know of a web server that could be embedded that will work with PHP (and would work with HipHop if we used that)? I have had a look at AppWeb but I wondered if there were any others.
I wonder if maybe I would be better moving my web app to something like Java and using Jetty?
Thanks,
If I understand your question correctly, all you need is to lookup the
$_SERVER['SERVER_NAME']
which would be different as clients uses different domains.
Regarding minimalistic webserver, I've found mongoose to flexible and easy to setup.
(uses php-cgi).
http://code.google.com/p/mongoose/
regards,
//t
This can be done by accepting wildcard subdomains in apache, and dispatching based on the server name in PHP.
An example apache configuration can be found here.
Not sure if I get correctly where you want to embed it. But if PHP is a requirement, there is the option of using http://pear.php.net/package/HTTP_Server. It's rather minimalistic, but should thus be easily adaptable and have less issues with a HipHop transformation.
The second alternative would be Nanoweb. While that's designed as a real webserver and feature-wise comparable to Apache, it's not suitable for embedding. But there are probably others, if you want to go that particular route.

Integrating java and apex (salesforce)

I'm a salesforce newbie and I need to integrate java business logic with apex pages.
Is it possibile to do it without using vwmforce? Note that I have to include my own and third party libraries as well.
Is there any tutorial/resource about that?
Thanks in advance
You could perform callouts from Salesforce to your separate Java code (as long as it's exposed as webservice or at least can accept HTTP message).
Read about Integration on the Force.com platform, there are many possibilities and examples.
In the API documentation most of the time there are Java code snippets listed, for example for creation of new records (scroll down to the middle of the page, "#" anchors seem to be brokes so I cannot give a direct link).
Generally you can both "push" (send from Salesforce notifications when something happens, synchronously or not) and "pull" data (periodically ask from your Java application for changes or send INSERTS etc. whenever something happens on your side).
But if you want to run your Java on Salesforce server and not on your own machine - tough, vmforce might be the only option. I haven't tried this one yet.
In the end under the Apex, Visualforce etc. there are Oracle databases and Java (with JSP), but I doubt they'll grant access to it ;)

Php/Java Integration

Have you experience of integration of php and Java? I've written a class in Java "Hello". Now I want to call its method from php when I create an instance of this class from php with
$obj = new Java(Hello);
Then it gives me fatal error. I've tried many times to setup php ini variables etc but I couldn't find anything. Please advice me how can I set it up.
Thanks in advance
Reference: http://php.net/manual/en/book.java.php
Have a look at:
PHP-Java Bridge
The PHP/Java Bridge is an
implementation of a streaming,
XML-based network protocol, which can
be used to connect a native script
engine, for example PHP, Scheme or
Python, with a Java virtual machine.
It is up to 50 times faster than local
RPC via SOAP, requires less resources
on the web-server side. It is faster
and more reliable than direct
communication via the Java Native
Interface, and it requires no
additional components to invoke Java
procedures from PHP or PHP procedures
from Java.
Could it be you are just missing the quotes around the Java Class? Also make sure you actually do have a Java VM on the machine you are trying to run the code on and make sure you have properly set up the config options. Also, the Java extension is a PECL extension and has to be installed. It is not part of the native distribution. Furthermore, the extension is considered unmaintained and dead, so you might want to have a look at the JavaBridge suggested elsewhere. Zend Server also brings a JavaBridge.
Check out this article: http://www.devshed.com/c/a/PHP/Using-PHP-with-Java/
They say it's possible (and how to do it). I've never done it, so I can't vouch for it...
In my experience the best way to interact between Java and PHP is through a WebService layer. NuSoap for PHP is very good, and you can consume the webservice in Java to create a stub that will build the request/response object.
There are many ways few are:
PHP Java Bridge
Java Integration in PHP
Using web services to pass data in between like SOAP
Using simple HTTP data passage between Java and PHP see (facejar uses the same technique)
Client site script (AJAX)
If you are after security, use option 1 otherwise I prefer using option 4 which is a bit faster when it comes to performance.

How to take a Java Web-application offline?

We develop Java Web-aps (Websphere, DB2) which display graphical and databased information. We would also like to offer the same application offline (distribution via CD/DVD) with online data-update. We have tried a number of alternatives in the past, but nothing has been really stable. What are the new best practices to take a Web ap plus data (in a small database) offline?
I don't know how well it works with the CD/DVD distribution front, but the first thing that comes to mind is Gears. On the .NET side of the fence there's Silverlight 2. Then there's the Mozilla Prism project, although I don't know how far advanced that is.
These are all designed for not just offline access, but mixed offline/online, talking to a server when it's available and working locally when necessary.
I'd suggest using Apache Derby as the database (also available as Sun's Java DB, and possibly still IBM Cloudscape (does that still have DB2 compatibility in place?)).
I'm sure there's plenty of Web servers/Servlet containers about. Apache Tomcat is the obvious one. An alternative approach would be to use an embedded native browser within a single Java process. That approach should be relatively hassle free for users and tech support, and you can just use WebStart to install and update.
If you're using EJBs and other nonsense, then there are similar freebies about. I understand Sun Glassfish is nice and fast starting.
You could create an image of your server as a VMware instance and distribute it with a copy of VMware player (licensing allowing of course). Personally I'd build it on top of a Linux distribution like CentOS5.
You can bundle a JRE along with JETTY server and use a different database e.g HSQLDB (that you can bundle inside the webapp itself).
If you are using an ORM tool to connect to database, you might not have to make many code changes for this.
A lot of Application server distribute their admin consoles like this.For e.g Weblogic admin console runs offline (it uses internal ldap server for its database)
Also as far as Google gears is concerned, they are also pretty much doing the same thing.
They have a server that is bundled along with SQLDB and they allow to synchronize the data between online offline app.
You can sync the data too (use webservices in the online app) and talk over https from the offline app to sync the data, if you need the sync feature.
Also you can check this link
http://developers.sun.com/learning/javaoneonline/2007/pdf/TS-69700.pdf

Categories