DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

The Latest Data Engineering Topics

article thumbnail
Why MongoDB is the Way to Go
Wherein we cover those rare possibilities which can hold you back from choosing MongoDB as your NoSQL database.
October 14, 2015
by Davis Kerby
· 18,264 Views · 11 Likes
article thumbnail
Downsides of Mixed Identifiers When Porting Between Oracle and PostgreSQL Databases
Mixing identifier types increases the potential for negative consequences when porting between Oracle and PostgreSQL databases.
October 11, 2015
by Dustin Marx
· 4,795 Views · 5 Likes
article thumbnail
Recipe: rsyslog + Kafka + Logstash
Here's a similar follow up to the previous rsyslog + Redis + Logstash recipe, this time with Kafka instead of Redis.
October 8, 2015
by Radu Gheorghe
· 15,503 Views · 8 Likes
article thumbnail
Microservices and Kerberos Authentication
How to use Kerberos authentication with microservice architectures and API gateways.
October 6, 2015
by Jethro Bakker
· 19,006 Views · 7 Likes
article thumbnail
Memory Layout of Multi-Dimensional Arrays
Multi-dimensional arrays are really fascinating for developers, and influence memory layout.
October 2, 2015
by Eli Bendersky
· 20,870 Views · 8 Likes
article thumbnail
Deal With Multi-Tenant Data in Solr
Different techniques can be used to handle multi-tenant data in Solr. This article discusses routing techniques you can use depending on the size and number of shards.
October 2, 2015
by Rafał Kuć
· 7,440 Views · 6 Likes
article thumbnail
The Limitations of the IoT and How the Web of Things Can Help
Understand the limitations of the Internet of Things and how the Web of Things can help build an application layer for the IoT.
September 28, 2015
by Dominique Guinard
· 27,317 Views · 6 Likes
article thumbnail
Problems Solved by IoT
We spoke with 20 executives across the IoT space about problems the Internet of Things are addressing.
September 24, 2015
by Tom Smith DZone Core CORE
· 37,139 Views · 5 Likes
article thumbnail
MySQL: Server vs. Client-Side Prepared Statements in Java
Basically, there are two ways of preparing a statement: on the server-side or on the client-side.
September 22, 2015
by Vlad Mihalcea
· 10,270 Views · 3 Likes
article thumbnail
Spring Security 4: JDBC Authentication and Authorization in MySQL
I am going to explain how to use Spring Security in a Spring MVC Application to authenticate and authorize users against user details stored in a MySQL Database.
September 18, 2015
by Priyadarshini Balachandran
· 192,665 Views · 10 Likes
article thumbnail
Microservices Versus Microsegmentation
An exploration of the difference between the concepts of microservices and microsegmentation.
September 17, 2015
by Lori MacVittie
· 7,122 Views · 5 Likes
article thumbnail
Optimizing a Hashing Strategy
Using two strategies in combination you can develop new hashing strategies to improve performance without having to use more memory or much more CPU.
September 16, 2015
by Peter Lawrey
· 14,001 Views · 1 Like
article thumbnail
Receive Notifications when a Table Record Changes with C#
The SQLDependency object represents a query notification dependency between an application and an instance of SQL Server. An application can create a SqlDependency object and register to receive notifications via the OnChangeEventHandler event handler every time a record is changed. However, what it cannot do, is returning the values for the inserted, modified or deleted record. So, supposing our application has a cache containing record monitored from SqlDependency, for every notification, in order to refresh the cache we have to execute again our select. SqlTableDependency SqlTableDependency is a generic C# component used to receive events containing the values for the modified, inserted or delete record. So, supposing our application has a cache filled with data got from a specific table, when its content change, we will receive an event containing a C# object with all property filled with column table values. How it Works When instantiated, SqlTableDependency create for us, a series of database objects, used to monitor a predefined table. The main object are: Queue: containg a message with the modified record values. Service Broker: insert the message in the queue. Table Trigger: for each insert, update or delete operation, prepare the an XML message and use the Service Broker to insert it in the queue. Watch Dog Time Out SqlTableDependency implement the IDisposable interface, in order to remove the database object created. Infact it is a good practice is to wrap SqlTableDependency within a using statement or, alternatively, call the Stop() method once we do not need any more notifications. So, when the application will not disconnect abruptly, this approach is enough to remove the SqlTableDependency infrastructure (Trigger, Service Broker service, Queue). However, when the application exits abruptly – that is not calling the Stop() method or not implementing the using statement - we need a way for cleaning up the SqlTableDependency infrastructure. The Start() method, has watchDogTimeOut optional parameter used to remove all the database objects. Its default value is 180 seconds: after this amount of time, if there are no listeners waiting for notifications, the SqlTableDependency infrastructure will be removed. How to Use In this example I created a very simple WPF application with a grid, simulating some stocks value. Let's start assuming the following database table: CREATE TABLE [dbo].[Stocks]( [Code] [nvarchar](50) NULL, [Name] [nvarchar](50) NULL, [Price] [decimal](18, 0) NULL) GO INSERT [dbo].[Stocks] ([Code], [Name], [Price]) VALUES (N'MCD', N'McDonald Corp', CAST(333 AS Decimal(18, 0))) INSERT [dbo].[Stocks] ([Code], [Name], [Price]) VALUES (N'NKE', N'Nike Inc', CAST(240 AS Decimal(18, 0))) INSERT [dbo].[Stocks] ([Code], [Name], [Price]) VALUES (N'DIS', N'Walt Disney Co', CAST(130 AS Decimal(18, 0))) INSERT [dbo].[Stocks] ([Code], [Name], [Price]) VALUES (N'UTX', N'United Technologies Corp', CAST(130 AS Decimal(18, 0))) INSERT [dbo].[Stocks] ([Code], [Name], [Price]) VALUES (N'MSFT', N'Microsoft Corp', CAST(130 AS Decimal(18, 0))) INSERT [dbo].[Stocks] ([Code], [Name], [Price]) VALUES (N'PFE', N'Pfizer Inc', CAST(130 AS Decimal(18, 0))) INSERT [dbo].[Stocks] ([Code], [Name], [Price]) VALUES (N'INTC', N'Intel Corp', CAST(130 AS Decimal(18, 0))) INSERT [dbo].[Stocks] ([Code], [Name], [Price]) VALUES (N'KO', N'Coca Cola Co', CAST(130 AS Decimal(18, 0))) GO This table is constantly updated with new stock values. We want keep update our grid without use of any polling system. So, what we need is a notification coming from the database every time a record in the table has been changed. We install the SqlTableDependency package from visual studio using the following command: PM> Install-Package SqlTableDependency Now we define a C# model mapping the interested table columns. public class Stock { public decimal Price { get; set; } public string Symbol { get; set; } public string Name { get; set; } } As you can see, model's properties name can have a different table column name. In this case, we need a mapper to correclty bind the values: var mapper = new ModelToTableMapper(); mapper.AddMapping(model => model.Symbol, "Code"); Finally we create our SqlTableDependency: _dependency = new SqlTableDependency(_connectionString, "Stocks", mapper); _dependency.OnChanged += _dependency_OnChanged; _dependency.OnError += _dependency_OnError; _dependency.Start(); Below the complete code: public partial class Window1 : Window { private IList _stocks; private readonly string _connectionString = "data source=.;initial catalog=TableDependencyDB;integrated security=True"; private readonly SqlTableDependency _dependency; public Window1() { this.InitializeComponent(); this.McDataGrid.ItemsSource = LoadCollectionData(); this.Closing += Window1_Closing; var mapper = new ModelToTableMapper(); mapper.AddMapping(model => model.Symbol, "Code"); _dependency = new SqlTableDependency(_connectionString, "Stocks", mapper); _dependency.OnChanged += _dependency_OnChanged; _dependency.OnError += _dependency_OnError; _dependency.Start(); } private void Window1_Closing(object sender, System.ComponentModel.CancelEventArgs e) { _dependency.Stop(); } private void _dependency_OnError(object sender, TableDependency.EventArgs.ErrorEventArgs e) { throw e.Error; } private void _dependency_OnChanged(object sender, TableDependency.EventArgs.RecordChangedEventArgs e) { if (_stocks != null) { if (e.ChangeType != ChangeType.None) { switch (e.ChangeType) { case ChangeType.Delete: _stocks.Remove(_stocks.FirstOrDefault(c => c.Symbol == e.Entity.Symbol)); break; case ChangeType.Insert: _stocks.Add(e.Entity); break; case ChangeType.Update: var customerIndex = _stocks.IndexOf(_stocks.FirstOrDefault(c => c.Symbol == e.Entity.Symbol)); if (customerIndex >= 0) _stocks[customerIndex] = e.Entity; break; } this.McDataGrid.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() => { this.McDataGrid.Items.Refresh(); })); } } } private IEnumerable LoadCollectionData() { _stocks = new List(); using (var sqlConnection = new SqlConnection(_connectionString)) { sqlConnection.Open(); using (var sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.CommandText = "SELECT * FROM [Stocks]"; using (var sqlDataReader = sqlCommand.ExecuteReader()) { while (sqlDataReader.Read()) { var code = sqlDataReader.GetString(sqlDataReader.GetOrdinal("Code")); var name = sqlDataReader.GetString(sqlDataReader.GetOrdinal("Name")); var price = sqlDataReader.GetDecimal(sqlDataReader.GetOrdinal("Price")); _stocks.Add(new Stock { Symbol = code, Name = name, Price = price }); } } } } return _stocks; } } As you can see from the code, only an initial select is performed to retrieve and populate the grid. Subsequent updates are done using the SqlTableDependency event handler: its receives a model object containing info about the record changed that we use to update our cache.
September 16, 2015
by Christian Del Bianco
· 141,428 Views · 5 Likes
article thumbnail
STRUTS 2 vs SPRINGMVC: Know the Difference & Choose the Best One Based On Your Requirements
Apache Struts 2 and SpringMVC, these two are the most popular and much talked about Java web frameworks today. Many of you might have worked with both of these frameworks, but which is one is better to use? What are the basic differences between both of these frameworks? Well, Apache Struts 2 is an elegant and extensible framework that is used for creating enterprise-level Java web applications. It is designed to streamline the development cycle, starting from building to deployment and maintenance of the application. In Struts, the object that is taking care of a request and routes it for further processing is known as “Action”. On the other hand, Spring MVC is a part of a huge Spring framework stack containing other Spring modules. This means that it doesn’t allow developers to run it without Spring, but the developers can run the Spring Core without Spring MVC. The Spring MVC (Model View Controller) is designed around a DispatcherServlet, which dispatches the requests to handler with configurable handler mappings, view resolution and theme resolution. While the objects responsible for handling requests and routing for processing in Struts called an Action, the same object is referred as Controller in Spring Web MVC framework. This is one of the very first differences between Spring MVC and Struts2. Struts 2 Actions are initiated every time when a request is made, whereas in Spring MVC the Controllers are created only once, stored in memory and shared among all the requests. So, Spring Web MVC framework is far efficient to handle the requests than Struts 2. If we talk about the features, Struts 2 and Spring MVC framework caters different level of business requirements. Let’s take a look at features offered by both of these frameworks. Struts 2 features Configurable MVC components, which are stored in struts.xml file. If you want to change anything, you can easily do it in the xml file. POJO based actions. Struts 2 action class is Plain Old Java Object, which prevents developers to implement any interface or inherit any class. Support for Ajax, which is used to make asynchronous request. It only sends needed field data rather than providing unnecessary information, which at the end improves the performance. Support for integration with Hibernate, Spring, Tiles and so on. Whether you want to use JSP, freemarker, velocity or anything else, you can use different kinds of result types in Struts 2. You can also leverage from various tags like UI tags, Data tags, control tags and more. Brings ample support for theme and template. Struts 2 supports three different kinds of themes including xhtml, simple and css_xhtml. On the other hand, Spring MVC framework brings totally different set of features. Spring MVC features Neat and clear separation of roles. Whether it is controller, command object, form object or anything else, it can be easily fulfilled with the help of a specialized object. Leverage from the adaptability, non-intrusiveness and flexibility with the help of controller method signature. Now use existing business objects as command or form object rather than duplicating them to extend the specific framework base class. Customizable binding and validation will enable manual parsing and conversion to business objects rather than using conventional string. Flexible mode transfer enables easy integration with the latest technology. Customizable locale and theme resolution, support for JSPs with or without Spring tag library for JSTL and so on. Leverage from the simple, but powerful JSP tag library known as Spring tag library. It provides support for various features like data binding and themes. Of course, Struts is one of the most powerful Java application frameworks that can be used in a variety of Java applications. It brings a gamut of services that includes enterprise level services to the POJO. On the other hand, Spring utilizes the dependency injection to achieve the simplification and enhance the testability. Both of these frameworks have their own set of pros and cons associated with it. Struts framework brings a whole host of benefits including: Simplified design Ease of using plug-in Simplified ActionForm & annotations Far better tag features OGNL integration AJAX Support Multiple view options and more However, the only drawback with Struts 2 framework is that it has compatibility issues and poor documentation. On the other hand, Spring MVC provides benefits like: Clear separation between controllers, JavaBeans models and views that is not possible in Struts. Spring MVC is more flexible as compared to the Struts. Spring can be used with different platforms like Velocity, XLST or various other view technologies. There is nothing like ActionForm in Spring, but binds directly to the domain objects. Code is also more testable as compared to the Struts. It is a complete J2EE framework comprising of seven independent layers, which simplifies integration with other frameworks. It doesn’t provide a framework for implementing the business domain and logic, which helps developers create a controller and a view for the application. However, like any other technologies or platforms, Spring MVC too suffers from several criticisms related to the complexity of the Spring framework. Final Verdict Either framework is a great choice. However, if you’re looking for the stable framework, Struts 2 is the right choice for you. On the other hand, if you’re looking for something robust, SpringMVC is perfect. Ensure that you review your exact requirements before choosing the framework!
September 15, 2015
by Manmay Mehta
· 32,333 Views · 4 Likes
article thumbnail
Data Conversion for SQL Server Integration Services (SSIS)
In the series of step by step lessons of SSIS (SQL Server Integration Services), this is part six in which we are going to learn a new control: Data Conversion.
September 15, 2015
by Rajat Jaiswal
· 18,131 Views · 1 Like
article thumbnail
Stored Functions as Stored Procedures in PostgreSQL PL/pgSQL
In this post, I look at a few tactics that can make the use of a stored function in PostgreSQL feel like using a stored procedure.
September 14, 2015
by Dustin Marx
· 68,770 Views · 2 Likes
article thumbnail
MySQL is a Great NoSQL Database
At Wix engineering, we’ve found that in most cases we don’t need a NoSQL database, and that MySQL is a great NoSQL database if it’s used appropriately.
September 12, 2015
by Aviran Mordo
· 19,611 Views · 6 Likes
article thumbnail
Java 8 Stream Performance Benchmarks
Learn all about Java stream performance with benchmarking and awesome metrics.
September 11, 2015
by Nicolai Parlog
· 14,291 Views · 4 Likes
article thumbnail
Customer Journey Analytics and Data Science
Deciphering the "nuts-and-bolts” of individual customer journeys (and deducing intent) is core to improving customer experience and driving brand loyalty.
September 9, 2015
by Ravi Kalakota
· 8,505 Views · 1 Like
article thumbnail
How to Set Up a Private Maven Repository in Amazon S3
Learn how to use Amazon S3 to keep private Maven artifacts to ensure your .jar files are visible only by your team.
September 9, 2015
by Yegor Bugayenko
· 9,597 Views · 3 Likes
  • Previous
  • ...
  • 818
  • 819
  • 820
  • 821
  • 822
  • 823
  • 824
  • 825
  • 826
  • 827
  • ...
  • Next
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook
×