Archive for category Technical Stuff

How to read maven-enforcer-plugin’s RequireUpperBoundDeps rule failure report

Scenario: To make use of a new feature in a certain dependency or to get a bugfix that’s causing your project pain, you bump the version of a dependency in your pom file — maybe the parent pom version. Then you type

mvn compile

…put your hands over your eyes, and gingerly press Enter.

And?

You may see something like this:

[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireUpperBoundDeps failed with message:
Failed while enforcing RequireUpperBoundDeps. The error(s) are [
Require upper bound dependencies error for org.slf4j:slf4j-api:1.7.11 paths to dependency are:
+-com.example.blah:blah-service:2.0.1-SNAPSHOT
  +-org.slf4j:slf4j-api:1.7.11
and
+-com.example.blah:blah-service:2.0.1-SNAPSHOT
  +-com.netflix.hystrix:hystrix-core:1.5.4
    +-org.slf4j:slf4j-api:1.7.11 (managed) < -- org.slf4j:slf4j-api:1.7.10
and
+-com.example.blah:blah-service:2.0.1-SNAPSHOT
  +-com.example.framework:example-core:0.5.9-SNAPSHOT
    +-org.slf4j:slf4j-api:1.7.11 (managed) < -- org.slf4j:slf4j-api:1.7.7
and
+-com.example.blah:blah-service:2.0.1-SNAPSHOT
  +-com.example.framework:example-core-data:0.5.9-SNAPSHOT
    +-org.slf4j:slf4j-api:1.7.11 (managed) < -- org.slf4j:slf4j-api:1.7.5
...

…only it goes on for screens and screens. What happened? Read the rest of this entry »

Advertisements

Leave a comment

@@ROWCOUNT = 1 after empty MIN() query

Ran across a surprising SQL Server thing today: I was updating a query If you run a query that returns no rows and use the MIN() aggregate function, you get an empty resultset as expected, but the @@ROWCOUNT variable is set to 1. If you write the query as a TOP(1) query in a situation where it returns no rows though, you still get an empty resultset but @@ROWCOUNT is set to zero as expected.

Example of this in action (tested on SQL Server 2012):

CREATE TABLE MyTable(MyId INTEGER, MyName NVARCHAR(128));
SELECT MIN(MyId)
FROM MyTable
WHERE MyName LIKE 'MyTag'
IF @@ROWCOUNT <> 0 PRINT 'Nonzero row count'
ELSE PRINT 'Zero row count'
--Output: Nonzero row count
SELECT TOP(1) MyId
FROM MyTable
WHERE MyName LIKE 'MyTag'
ORDER BY MyId
IF @@ROWCOUNT <> 0 PRINT 'Nonzero row count'
ELSE PRINT 'Zero row count'
--Output: Zero row count
DROP TABLE MyTable;

Leave a comment

Indexing only null column values in Oracle

We have a table that can have tens or hundreds of millions of rows in it, and in this table there is a certain column. This column usually—typically—generally—has non-null hash values in it.

In unusual cases though, that column can be NULL. And the thing is, there are times when the interesting rows, the rows we want to gather together and do something with, are exactly the rows where that column is null.

Table scans to find the rows where the column is NULL are expensive, so naturally we want to index this column. But since non-null values in this column are a hash and we only ever care about the NULL values, we’d like to avoid the time and space overhead of indexing the non-null values. We’d like a partial index of only the rows where the column is NULL… Read the rest of this entry »

,

Leave a comment

Change default runlevel (target) on Fedora

I’m running on Fedora 20, and the graphical boot (Plymouth-something-something) sometimes waits a long time and then times out, which when it happens makes the computer take several minutes to boot. This doesn’t happen if I boot to “runlevel 3” (now called multi-user.target) and then run startx from there.

You can change the default target to “runlevel 3” like this:
systemctl set-default multi-user.target

Leave a comment

How to have the bash prompt display the full current working directory

To display the full working directory at the bash prompt (Linux command line), edit /etc/bashrc and where the PS1 variable is set, change \W to \w .

I’m running Fedora 19.

Leave a comment

How to remote restart your Windows PC

You’re remoting in from home and some app goes haywire on your (Windows) work PC. You’ve already asked your co-worker to power cycle your PC but now the problem is happening again. You don’t want to keep bugging your co-worker and you don’t want to have to drive in to work. You could have enabled the Remote Registry service, but you really don’t want to do that. Are there any other options?

There is, and a pretty simple one. You can issue a shutdown command from another PC on your network. The trick is to establish a connection to your main PC with your username first. At a command prompt on the second PC then:

net use \\MyMainPC\IPC$ /user:mydomain\myuser *
shutdown -m \\MyMainPC -r

There are other options you can send to the shutdown command, but this gets us (re)started. I tested this on Windows 7.

Leave a comment

Rough notes on SQL Server bulk insert

(I recently found these notes that I had written up in January and Feburary of 2010. I am posting them in the hope that they may be a help to me and others, even in their rough form.)

It worked to just generate all the fields, with empty fields for ones I didn’t care to fill in.

for %d in (Foo Bar Baz Quux) do bcp MyDatabase.dbo.%d format nul -T -c -f %d.fmt

This resulted in the creation of Foo.fmt, Bar.fmt, Baz.fmt, and Quux.fmt files.

Foo.fmt:

9.0
10
1       SQLCHAR       0       22      "\t"   1     FooID                            SQL_Latin1_General_CP1_CI_AS
2       SQLINT        0       4       "\t"   2     FooTypeID                        ""
3       SQLINT        1       4       "\t"   3     TitleID                            ""
4       SQLNCHAR      2       100     "\t"   4     LastName                           SQL_Latin1_General_CP1_CI_AS
5       SQLNCHAR      2       100     "\t"   5     FirstName                          SQL_Latin1_General_CP1_CI_AS
6       SQLNCHAR      2       100     "\t"   6     MiddleName                         SQL_Latin1_General_CP1_CI_AS
7       SQLNCHAR      2       100     "\t"   7     Department                         SQL_Latin1_General_CP1_CI_AS
8       SQLNCHAR      2       200     "\t"   8     Company                            SQL_Latin1_General_CP1_CI_AS
9       SQLCHAR       2       22      "\t"   9     OrgID                              SQL_Latin1_General_CP1_CI_AS
10      SQLTINYINT    0       1       "\r\n"   10    Active                             ""

Read the rest of this entry »

, ,

Leave a comment