Migrating Oracle to PostgreSQL
Random Thoughts on Java Programming
by
4h ago
So at work we're currently trying to see if we can move away from Oracle and onto PostgreSQL. I expect this to be a long process. This blog post is here to document some of the issues we ran into and also remember references I found. Migrating schema and data There are several tools that can migrate the schema and the data from Oracle to Postgres. There are some differences in what both database support. See reference [1]. Make changes to SQL Scripts References [1] Hackermoon - How to Migrate from Oracle to PostgreSQL https://hackernoon.com/how-to-migrate-from-oracle-to-postgresql Postgres Wik ..read more
Visit website
SQL: Concat operator and Spaces
Random Thoughts on Java Programming
by
1M ago
So I had a pressing need to query my database and concatenate several values from a row together (using either concat or ||), but with spaces in between. But I don't want two spaces if the value in between is empty. It is surprisingly difficult to do in SQL, but there are some options available. First the data: TITLE FIRSTNAME MIDDLENAME FAMILYNAME Ichabod Crane Dr. Thomas Lancaster Philip Martin Brown select TITLE || ' ' || FIRSTNAME || ' ' || MIDDLENAME || ' ' || FAMILYNAME from PERSON; So, if you use the SQL statement above, you get the problem, extraneous spaces. For example ..read more
Visit website
The DUAL table
Random Thoughts on Java Programming
by
2M ago
I'm working with Oracle databases (version 19 for now), and I always wondered about the weird DUAL table1 that I require in my work. Things like this: select sysdate from dual; select seq_s_ordertable.nextval from dual; Well, apparently we have Charles "Chuck" Weiss2 to thank for it. One of the reasons is that the FROM clause in Oracle SQL syntax is mandatory. Interestingly, Charles originally created the DUAL table with two rows, hence the name DUAL. Nowadays it's one row, but the name's stuck. It's part of the Data Dictionary of the SYS user. Changing the DUAL table will cause problems!3 Ref ..read more
Visit website
Using Java to Zip/Unzip files
Random Thoughts on Java Programming
by
2M ago
There's been a ZipFile class in Java sinds a long time. But nowadays sinds JDK7 there's also a ZipFileSystem which is a bit easier to work with in some cases and can do more things. Below are two examples, one using ZipFile and one using ZipFileSystem. Using ZipFile Unzipping works as follows: @Test public void testOldZip() throws URISyntaxException, IOException { URL resource = UnzipperTest.class.getResource("/test.zip"); assert resource != null; Path path = Path.of(resource.toURI()); try (var zipFile = new ZipFile(path.toFile())) { Enumeration<? extends ZipEntr ..read more
Visit website
Streams and Filters
Random Thoughts on Java Programming
by
2M ago
A simple little thing. I like to use streams and filters, and I was wondering what's the best way to go about some things. For example: I wish to search for a person in a list of Persons. @Test public void testSimple() { Person personToFind = new Person(null, "Mr.", "Bear", "Netherlands"); Person otherPersonToFind = new Person(null, "Linda", "Lovelace", "England"); assertThat(Persons.get().stream() .filter(person -> Objects.equals(personToFind.name(), person.name()) && Objects.equals(personToFind.surname(), person.surname()) && ..read more
Visit website
Is Stream.findFirst() Short-circuited?
Random Thoughts on Java Programming
by
2M ago
So, the assumption is: if I use findFirst on a stream, none of the items in the stream after the first match are evaluated. I assumed that it was, and it is, but it's always nice to see this verified in a simple test. private List<String> list = new ArrayList<>(); private boolean add(String message, boolean returnValue) { list.add(message); return returnValue; } public boolean check() { List<Supplier<Boolean>> checks = new ArrayList<>(); checks.add(super::onLeave); checks.add(() -> { list.add("First expression"); retu ..read more
Visit website
Refactoring
Random Thoughts on Java Programming
by
3M ago
So, I saw some code that I didn't like, and I decided to refactor it. The code was thusly. public boolean onLeave() { boolean valid = super.onLeave(); Account account = database.getAccount(); ShoppingList shoppingList = database.getShoppinglist(account); if (valid) { valid = !shoppingList.isEmpty(); } if (valid) { valid = !blockedAccounts.contains(account); } if (valid) { String country = account.getPerson().country(); valid = webshop.alsoShipsTo(country); } if (valid) { valid = account.hasCreditcardAttached ..read more
Visit website
Is Java Pass-by-value or Pass-by-reference?
Random Thoughts on Java Programming
by
3M ago
I thought I'd write a quick test to get things straight ..read more
Visit website
Adding a device to a raid with mdadm
Random Thoughts on Java Programming
by
3M ago
Reordering partitions to make room So my current hard drives are: # lsscsi [0:0:0:0] disk ATA Samsung SSD 860 1B6Q /dev/sda [4:0:0:0] disk ATA WDC WD4003FZEX-0 1A01 /dev/sdb [5:0:0:0] disk ATA WDC WD5000AAKS-0 3B01 /dev/sdc [5:0:1:0] disk ATA ST2000DM001-1CH1 CC29 /dev/sdd [10:0:0:0] disk WD Ext HDD 1021 2021 /dev/sde [11:0:0:0] disk WD Ext HDD 1021 2021 /dev/sdf I had a lot of unused space on /dev/sdb, and thought I could rearrange the partitions and use it as an additional device in my (software) RAID ..read more
Visit website
The Java Playground
Random Thoughts on Java Programming
by
3M ago
Apparently there's an official Java Playground on https://dev.java/. They are working on using the Playground in your own webpages. It is primarily created for developers to play around with the new Java, without having to install the new java. But it's early and they have plans for it. References dev.java - The Java Playground https://dev.java/playground/ dev.java https://dev.java ..read more
Visit website

Follow Random Thoughts on Java Programming on FeedSpot

Continue with Google
Continue with Apple
OR