Showing posts with label Ado.Net. Show all posts
Showing posts with label Ado.Net. Show all posts
Thursday, October 13, 2016
Using .NET libraries from JAVA
Recent popularization of net offerings seems to resolve virtually any interoperability issue between JAVA and .Web programs because of platform independence and universal transport channel. And that is actual, the pliability and universality of internet offerings founded options in mixture with good-defined requisites makes this technology a winner in virtually eighty% might be even ninety% of cases. However fairly there are no cons?
Of direction there are and circumstances unresolvable with internet carrier come out on occasion in many crucial initiatives. The major purpose why internet offerings does no longer slot in each case is regularly performance, protection and development costs. The determination the right way to clear up these disorders mostly relies on system architects and it might be probably the most essential choice in challenge entailing quite a lot of specific consequences.
How you can identify in case your case will have to be solved with net offerings?
If you are the one to make a decision you must recollect as a minimum following aspects. Let’s say we now have .Web library with some legacy business common sense or relevant encryption/buying and selling algorithm or .Net simplest API to corporate CRM, here is how we could analyse this:
examine in case your requirement is worth constructing dedicated customer-server infrastructure. Will you ought to run go desktop executions? Don't forget that net provider is consumer server. In our case we might must construct web provider on .Internet side and wrap selected approaches in our WCF SVC or ASMX interface. If it’s just one approach and dll located on the identical laptop as our JAVA software is it worth to host internet server and consume it on neighborhood host? Obviously not.
Examine if you could have enough money it. Each web provider name has rather colossal overhead on each request message if we use xml protocol every easy approach is wrapped in xml envelope and handed in http request ingesting internet server resources, and together with all different delays of transport channel, serialization/deserialization and internet request processing correctly if it is trading algorithm that locations transactions on currency trading or inventory market we must restrict it… identical in all other circumstances have been we make various requests in short time or we just rely on speed we must now not add that so much of buzz into our communication.
Investigate if it’s no longer too simple. If the library that we use comprises single system for encrypting or calculating anything, must we make: web provider, consumer, host web server, permit http conversation, build .Web net mission simply to load one approach from one dll and get in touch with it as soon as in lifetime of our JAVA challenge? No.
Investigate if it’s now not too elaborate. Regularly the amount of code that we need to reuse in JAVA could be oppositely too massive. Wrapping countless numbers of methods in web carrier and passing hundreds of execution places by way of web provider customer would rate us rather a lot in progress and additional maintenance. Simple illustration would be the case were we want to construct JAVA software with WPF interface, i will be able to’t assume exposing all WPF framework classes by way of internet offerings enforcing call-backs and constructing out of it responsive UI.
We could anticipate that up to now we have now determined if our solution must and would be implemented with net offerings interoperability technique, but what must we do if it does now not fit in there? Most of builders most often don't meet such problems but as a result if they do it’s rough to find a excellent solution. It is not that effortless to get JAVA and .Web work collectively by way of our possess, with out spending for it extra time than entire our undertaking is deliberate for. And of course we must remember that it isn't a excellent apply to reinvent the wheel.
What are the possible choices to make use of .Internet libraries from JAVA application?
Most of us does no longer comprehend that there are some native JAVA to .Web bridges to be had in the marketplace whereas these solutions does exactly this what web carrier does not so they fill our gap of 20% circumstances perfectly.
Native JAVA to .Net Bridge leverages JAVA native methods invocation capabilities with native platform exact verbal exchange channels and direct invocations on .Web objects. In this approach we get .Net procedure being hosted natively for our JAVA utility giving us entry to any .Internet library directly from JAVA code like they were native JAVA objects. When you consider that of direct invocation passing between tactics we get instant execution with out delays, overhead and further infrastructure.
Moreover we get a few additional advantages, these are: efficient call-backs mechanism if you want to with no trouble subscribe cross platform movements, entry to any .Net library without any wrappers and implementation on .Web side, lifecycle of objects and methods bound into one runtime and no client server solutions accordingly no additional side merchandise to keep and display.
JAVA to .Internet interop market is not large. There are simplest few carriers who managed to supply efficient and flexible adequate solutions that could be nontoxic for initiatives of any measurement.
Picking out proper bridge will have to be pushed by using simplicity of usage, performance and flexibility. This year there used to be new answer launched called Javonet. It appears to be very appealing because of a number of causes. The mission was once firstly born as tutorial study for object database techniques at Polish-jap Institute of information science. From very beginnig it was aimed on high efficiency.
For the duration of commercialization it was improved with very programmer-pleasant API and many valuable aspects. Javonet offers access to any .Net library nonetheless it's customized, part of .Net framework or delivered by using 1/3 celebration firms. There aren't any changes in .Net code required and libraries can be loaded from neighborhood directories or GAC. And it supports both x86 and x64.
Having entry to any library instantly we are able to just reference them from our JAVA code and work on objects and courses from such library like they have been native JAVA objects. Javonet API exposes specified NObject variable for JAVA which works as manage to .Net object. For the reason that all invocations and references are performed in runtime we will initialize and make use of any object, process, property or discipline making use of reflection-type syntax by way of supplying names in steady strings.
JAVA to .Web bridge like Javonet handles internally rubbish collector moves and exceptions with a purpose to seize .Internet exceptions on JAVA side and if our NObject control is collected on JAVA aspect corresponding object will get disposed on .Net aspect as good. All these points makes such bridging resolution a huge leading edge technological know-how that gives you us all-in-one framework for making use of .Net code from JAVA.
The possibilities of these options are worth exploring as high efficiency and easy utilization results in new strategies of how we would apply this in our tasks. In tutorial and samples we will read step by step publications make full JAVA software with WinForms or WPFinterface or how you can lengthen .Internet category in JAVA, typically even for tremendously experienced builders these sort of solutions looks like magic.
I totally encourage all JAVA builders to become aware of and test these solutions to preserve in intellect new choices how CLR and JVM interoperability issues would be resolved in state-of-the-art world.
Wednesday, December 21, 2011
Get The OUTPUT Paramete Value from SP Using Dot Net
Get The OUTPUT Paramete Value from SP Using Dot Net using asp.net. This code can be used to get the data from database using Out parameter
Imports System.Data
Imports System.Data.SqlClient
Partial Class SP
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Handles Button1.Click
Try
Dim Con As New SqlConnection
Con.ConnectionString =
"Password=RR;Persist Security Info=True;
User ID=RR;Initial Catalog=RR;Data Source=RR"
Con.Open()
Dim INparam, OutPram As New
SqlParameter
INparam.Direction =
ParameterDirection.Input
INparam.SqlDbType = SqlDbType.Int
INparam.ParameterName =
"@ID"
INparam.Size = 20
INparam.Value = Textbox1.text
OutPram.Direction =
ParameterDirection.Output
OutPram.SqlDbType = DbType.String
OutPram.ParameterName =
"@Name"
OutPram.Size = 200
Dim com As New SqlCommand
com.Connection = Con
com.CommandType =
CommandType.StoredProcedure
com.CommandText =
"spGetOutput"
com.Parameters.Add(INparam)
com.Parameters.Add(OutPram)
com.ExecuteNonQuery()
Label1.Text = OutPram.Value()
Catch ex As Exception
End Try
End Sub
End Class
Sunday, December 18, 2011
Creating SQL Connection
Showing how to create a sql connection by code...(Basic). Type this code to create a sql connection using ADO.Net
//con is the object of SqlConnectoin_
SqlConnectoin con= new SqlConnetoin();
con.ConnectionString = "Data Source
=Sqlservername ; Initial Catalog = table name; Integrated Security =
True";
con.Open();
//Here Sqlserver name = your computer name
(You can see your computer name by :
//If you are connecting sql with user id and
password than remove Integrated security and
type :
SqlConnectoin con= new SqlConnetoin();
con.ConnectionString = "Data Source
=Sqlservername ; Initial Catalog = table name; User id = youruserid; password =
yourpassrd";
con.Open();
Read More......Thursday, December 15, 2011
SqlDataReader to Retrieve Multiple Rows
SqlDataReader to Retrieve Multiple Rows
The SqlDataReader approach to retrieve multiple rows is illustrated in the following code fragment.
using System.IO;
using System.Data;
using System.Data.SqlClient;
public SqlDataReader RetrieveRowsWithDataReader()
{
SqlConnection conn = new SqlConnection(
SqlCommand cmd = new SqlCommand("DATRetrieveProducts", conn );
cmd.CommandType = CommandType.StoredProcedure;
try
XmlReader to Retrieve Multiple Rows
XmlReader to Retrieve Multiple Rows
You can use the SqlCommand object to generate an XmlReader object, which provides forward-only, stream-based access to XML data. The command (usually a stored procedure) must generate an XML-based result set, which for SQL Server 2000 usually consists of a SELECT statement with a valid FOR XML clause. The following code fragment illustrates this approach:
You can use the SqlCommand object to generate an XmlReader object, which provides forward-only, stream-based access to XML data. The command (usually a stored procedure) must generate an XML-based result set, which for SQL Server 2000 usually consists of a SELECT statement with a valid FOR XML clause. The following code fragment illustrates this approach:
public void
RetrieveAndDisplayRowsWithXmlReader()
{
using( SqlConnection conn = new SqlConnection(connectionString) )
{;
SqlCommand cmd = new SqlCommand("DATRetrieveProductsXML", conn
);
cmd.CommandType = CommandType.StoredProcedure;
try
{
conn.Open();
XmlTextReader xreader = (XmlTextReader)cmd.ExecuteXmlReader();
while ( xreader.Read() )
{
if ( xreader.Name == "PRODUCTS" )
{
string strOutput = xreader.GetAttribute("ProductID");
strOutput += " ";
strOutput += xreader.GetAttribute("ProductName");
Console.WriteLine( strOutput );
}
}
xreader.Close(); // XmlTextReader
does not support IDisposable so it can't be
// used within a using
keyword
}
}
The preceding code uses the following stored procedure:
CREATE PROCEDURE DATRetrieveProductsXML
AS
SELECT * FROM PRODUCTS
FOR XML AUTO
GO
Subscribe to:
Posts (Atom)
-
In object-oriented languages the term "interface" is often used to define an abstract type that contains no data but exposes behav...
-
The following article discusses the WPF command binding feature with relation to Mouse clicks. One of WPF powerful features is the bindin...