Initializing A ResultSet

Question:
I am building a prototype but am trying to make the code as reuseableas possible. To test the prototype, I need to simulate a ResultSetbeing returned from a database. When my backend program simulating adatabase tries to add columns into the ResultSet, I get errormessages that the ResultSet has not been initialized, which is true.

How would I go about initializing this ResultSet given that I have nodatabase and am currently reading a file and trying to populate theResultSet using methods within ResultSet.

Answer:
ResultSet is an interface of which a subclass is instantiated in a JDBCdriver-specific manner.You have three main options. You can write your own dummy JDBCdriver, you can write your own dummy ResultSet implementation thatcan be populated with test data, or you can create a dummy databaseand use a real JDBC driver. Of all of your options, the third is themost desirable. There is really no reason to be writing a prototypewithout a test database. There are JDBC drivers for everything fromAccess files to Open Source databases such as PostgreSQL. Workingwith a test database from the get go is less time consuming thanwriting your own JDBC test classes and should produce a betterprototype since your development environment will more accuratelyrepresent your eventual deployment environment.

That said, if youare working with limited computing resources and cannot use a testdatabase, you should be able to implement your own JDBC 2.0 dummyResultSet class for testing purposes in a non-excessive amount oftime.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

iOS app development

The Future of iOS App Development: Trends to Watch

When it launched in 2008, the Apple App Store only had 500 apps available. By the first quarter of 2022, the store had about 2.18 million iOS-exclusive apps. Average monthly app releases for the platform reached 34,000 in the first half of 2022, indicating rapid growth in iOS app development.

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a