vikarjramun

1

votes
0

answer
50

views

Determine cause of SQLConstraintViolationException

I am currently writing some code that works on updating values in a database. I have a table with three constrains: a primary key (composite), a foreign key (not composite), and a unique key (composite). My table (the output of show create table ItemAttributeMaster): CREATE TABLE `ItemAttributeMast...
vikarjramun
1

votes
1

answer
141

views

Unable to read files from ZIP file input stream

I have a Zip file that I am trying to read. I do not want to use a ZipFile because in the future, I would like to do this for data that is not from a file. This is what I have tried so far. Instead of printing the contents of res00000.dat, it prints an empty line. I do not know how to fix this ZipIn...
vikarjramun
1

votes
2

answer
786

views

Parsing URI parameters in a RESTful API

How should I approach parsing URI parameters in a REST API. For example: http://api.example.com/item/ [{{ItemID}} [/{{Property}}]] The following requests should all be valid: http://api.example.com/item http://api.example.com/item/ http://api.example.com/item/1 http://api.example.com/item/1/ http://...
vikarjramun
1

votes
1

answer
995

views

Using Mockito w/o Maven

I am making a small java library to parse URI parameters. I implemented it, and am in the process of making JUnit tests for it. I realized that I needed to use a mocking framework, and I did some research and chose Mockito. But since I am not using Maven or Gradle, I do not know how to include the M...
vikarjramun
1

votes
1

answer
167

views

Will compilers optimize out unused private methods?

Does javac leave out private methods if they are inlined? For example public class Test { public static void main(String[] args){ System.out.println(sayHello()); } private static String sayHello(){ return 'Hello World'; } } But what if this method is then accessed by reflection? System.out.println(T...
vikarjramun
1

votes
1

answer
57

views

How to unit test DAOs without ORM

I am writing a JAX-RS web service right now. My database logic has been compartmentalized into DAO interfaces (e.g. interface ItemDAO and concrete implementation class JDBCItemDAO), which are injected into my controllers via Dependency Injection. Right now, it is relatively simple to unit test my co...
vikarjramun
1

votes
1

answer
134

views

Windows and Linux Simultaneous EC2 Instances on AWS Free Tier

I am running a Linux server with 10GB of EBS Storage for personal projects on AWS's free tier. I also want to create another server on that same account, but I would rather not spend anything. I tried to create a Windows server (which has a seperate compute-hours allowance), and gave it the remainin...
vikarjramun
1

votes
3

answer
76

views

Significance of finally block [duplicate]

This question already has an answer here: Why use finally instead of code after catch [duplicate] 14 answers What is the significance of the Finally block in a Try...[Catch]...Finally block? Isn't this code Resource r; try{ r = new Resource(); r.methodThatThrowsException(); } catch (Exception e) {...
vikarjramun
1

votes
1

answer
88

views

JLabel moves with text entered into JTextArea

I am creating a swing file editor. I have a JLabel, and a JTextArea in my JFrame. When I type in the JTextArea, I notice the JLabel moving. Here is a Screencastify of this: Screencastify Is this related to the BoxLayout I am using? Can you please help me explain this behavior, and possibly solve it?...
vikarjramun
11

votes
3

answer
2.8k

views

JSP - What is wrong with scriptlets, and what to use instead [duplicate]

This question already has an answer here: How to avoid Java code in JSP files? 29 answers I read about JSP in a book many years ago, and recently decided to learn on my own. I now know how to use JSP scriptlets, expressions, and declarations But I have read in many places (on this site and elsewher...
vikarjramun