Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
covener
Jan 10, 2004

You know, for kids!

ahmeni posted:

Are heap dumps with tools like jmap very useful from our operations non-developer perspective?

Yes, large leaks can sometimes be very obviously traced back in the tools to a single map, classloader, etc that will very much get you in the neirhborhood of the culprit. The ops guys might need to pair up with a JVM guru the first few times to understand the tools you have available, but it is not anything like source-level debugging.

Adbot
ADBOT LOVES YOU

deedee megadoodoo
Sep 28, 2000
Two roads diverged in a wood, and I, I took the one to Flavortown, and that has made all the difference.


As an operations engineer who supports java applications the biggest thing I'm looking for when I load up jmanage are obvious memory or connection leaks related to recent code deploys. If I can't pin it down to something obvious I'm dropping it. We operations folks don't usually have a ton of time to spend picking at a problem in code.

mister_gosh
May 24, 2002

Is there a way, using the java.awt.Desktop, or something very similar, to select a file?

I can use Desktop.open() to open to a file location in Windows, but then I want it to select a particular file in that directory.

Rexxed
May 1, 2010

Dis is amazing!
I gotta try dis!

mister_gosh posted:

Is there a way, using the java.awt.Desktop, or something very similar, to select a file?

I can use Desktop.open() to open to a file location in Windows, but then I want it to select a particular file in that directory.

Seems like you can do that by launching explorer with the /select option:
explorer.exe /select,"C:\Folder\subfolder\file.txt"

Copied from: http://stackoverflow.com/questions/13680415/how-to-open-explorer-with-a-specific-file-selected

mister_gosh
May 24, 2002

Rexxed posted:

Seems like you can do that by launching explorer with the /select option:
explorer.exe /select,"C:\Folder\subfolder\file.txt"

Copied from: http://stackoverflow.com/questions/13680415/how-to-open-explorer-with-a-specific-file-selected

Thanks!!

BexGu
Jan 9, 2004

This fucking day....
Any one know of any java classes that do the same things (or similar) to this Python script? (Creating Human readable UUIDs)

https://github.com/zacharyvoase/humanhash

BexGu fucked around with this message at 22:00 on Nov 5, 2013

Gravity Pike
Feb 8, 2009

I find this discussion incredibly bland and disinteresting.

BexGu posted:

Any one know of any java classes that do the same things (or similar) to this Python script? (Creating Human readable UUIDs)

https://github.com/zacharyvoase/humanhash

Google is turning up like 2 people who have done a Bubble Babble assignment. Beyond that, you might be best off reimplementing that Python script on your own.

PleasantDilemma
Dec 5, 2006

The Last Hope for Peace
Hello! I'm a PHP developer who would like to get into Java web programming. I'm just not sure where to start. The Java world is pretty huge. Do I need to learn Ant, Maven, or Gradle? Should I start with one of the many web frameworks out there, or do something more low level? And what is low level? Servlets? JSP? I'm not sure what the difference is. And if I pick a framework, it seems that some need a container like tomcat to run and others can be their own container, is that a big factor?

I learned Java syntax in school but we did simple GUI and data structure stuff, we never needed a build tool besides what Eclipse could do for us. Trying to make something real in Java looks like a daunting task. I want to stick with web stuff since that is what I know, but I don't know where to start.

Volguus
Mar 3, 2009

mister_gosh posted:

Is there a way, using the java.awt.Desktop, or something very similar, to select a file?

I can use Desktop.open() to open to a file location in Windows, but then I want it to select a particular file in that directory.

Why do you need to do this? The suggestion with launching explorer.exe works, but what is the reason for such a requirement? Going this route opens up a potential can of worms. I know that now all your clients are using windows xp 32 bit, but what if in the future they'll go to something better? They'll run your app on a Mac? Or ... even worse, Linux? And they'll want this exact feature there?
What do they want to do with explorer and the file once they have it selected? Open it up in the default editor? Desktop.open will do that for you. Copy it somewhere? You can provide that feature yourself.

If there would be a way to make your client happy without launching explorer.exe, try to go that route. The pain maintaining such a thing is usually not worth it.

mister_gosh
May 24, 2002

We have a content management system with a Swing interface. 95% of users work is done within the GUI, but there's a small percentage of the time where they need to go to the local location of the file they are working with (which are all resident on their system). The reason could be anything. So I'm putting in an option to right click on the file to show it in Windows explorer (all users are Windows). Rather than just Desktop.open() the directory the file is in, it seems ideal to select it. I could detect whether it is Windows and only do the select if it is Windows, but it's unnecessary as this is very internal.

One example might be that they may have a graphic file or an html file they want to open in an editor different from their default editor.

Ideally we'd never allow them access but there are third party tools and other environments that our users work with, and we can't limit them to finding their source files.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

PlesantDilemma posted:

Hello! I'm a PHP developer who would like to get into Java web programming. I'm just not sure where to start. The Java world is pretty huge. Do I need to learn Ant, Maven, or Gradle? Should I start with one of the many web frameworks out there, or do something more low level? And what is low level? Servlets? JSP? I'm not sure what the difference is. And if I pick a framework, it seems that some need a container like tomcat to run and others can be their own container, is that a big factor?

I learned Java syntax in school but we did simple GUI and data structure stuff, we never needed a build tool besides what Eclipse could do for us. Trying to make something real in Java looks like a daunting task. I want to stick with web stuff since that is what I know, but I don't know where to start.

Java and its eco system is loving huge and trying to digest it all at once isn't really feasible. Pick a project you want to do (or port one of your PHP projects) and just bang away at it and pick it up as you.

To answer your questions I would just start with Maven, Ant can be learned in a pinch if needed, I haven't used Gradle so I can't comment on that.

Servlets are pretty much the lowest you can go. A JSP is a view and would be close to your .php file but it is generally frowned upon to put processing in them, you should use JSTL (I think, haven't been in the web game outside of services in a while)

Just use Tomcat, it will suit must of your needs. Once you go corporate you may need to switch to JBoss but Tomcat will be a good base.

Volguus
Mar 3, 2009

mister_gosh posted:

...(all users are Windows)...

This is true today. It will be true tomorrow. The day after ... it may not. But, if you have to do it, then well, do what you gotta do. I'm not saying to prevent them from accessing their files, was just thinking that there may be a better way of providing them with the features that they want, instead of going native. With long lived projects (5+ years), when features like this creep into it, it becomes a nightmare to maintain for future developers. It may be better (from design perspective) to go the JNI route, and do whatever you need to do from native code, and just keep the java code clean. Such that when other OS-es will be used, the developers would just need to provide the library for that OS, that will implement the required native functions.

From a different perspective: if all my clients are windows, they will always be windows and they will never ever change, why do I need to write my UI in java then? Going native would provide them with a much more responsive interface. Of course, the downside could be that developers may not be familiar with C/C++ windows programming, but that can be learned. It's not magic.


But, the explorer.exe solution is the easiest and the fastest one to implement.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

lamentable dustman posted:

Java and its eco system is loving huge and trying to digest it all at once isn't really feasible. Pick a project you want to do (or port one of your PHP projects) and just bang away at it and pick it up as you.

To answer your questions I would just start with Maven, Ant can be learned in a pinch if needed, I haven't used Gradle so I can't comment on that.

Servlets are pretty much the lowest you can go. A JSP is a view and would be close to your .php file but it is generally frowned upon to put processing in them, you should use JSTL (I think, haven't been in the web game outside of services in a while)

Just use Tomcat, it will suit must of your needs. Once you go corporate you may need to switch to JBoss but Tomcat will be a good base.

Agreed with everything you just said but I would recommend GlassFish over Tomcat for someone just starting out today. The concepts you learn will port over well to any of the other servers, butt the admin console is a lot easier to use and understand at first and don't require loving around with XML configs until you need to configure very advanced features. ALso there are plugins for it just like Tomcat in every IDE which will help with deploying your projects straight from the IDE.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

PlesantDilemma posted:

Hello! I'm a PHP developer who would like to get into Java web programming. I'm just not sure where to start. The Java world is pretty huge. Do I need to learn Ant, Maven, or Gradle? Should I start with one of the many web frameworks out there, or do something more low level? And what is low level? Servlets? JSP? I'm not sure what the difference is. And if I pick a framework, it seems that some need a container like tomcat to run and others can be their own container, is that a big factor?

I learned Java syntax in school but we did simple GUI and data structure stuff, we never needed a build tool besides what Eclipse could do for us. Trying to make something real in Java looks like a daunting task. I want to stick with web stuff since that is what I know, but I don't know where to start.

I haven't used it before, but the Play Framework seems like a good way to hit the ground running.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

fletcher posted:

I haven't used it before, but the Play Framework seems like a good way to hit the ground running.

Play and other big frameworks like Spring are very popular, but they're also gigantic. From what I've seen they have a lot of dependencies and use a whole lot of their own way of thinking, so if you're going to subscribe to one of those, you're getting pretty deep into custom APIs and you're going to be married at the hip. Not that that's the end of the world.

But if you're just trying to learn some basic Java web stuff, I'd honestly start with just throwing together some JSPs. Then write some servlets to drop in Tomcat. Then maybe you wanna learn Play.

Hard NOP Life posted:

Agreed with everything you just said but I would recommend GlassFish over Tomcat for someone just starting out today. The concepts you learn will port over well to any of the other servers, butt the admin console is a lot easier to use and understand at first and don't require loving around with XML configs until you need to configure very advanced features. ALso there are plugins for it just like Tomcat in every IDE which will help with deploying your projects straight from the IDE.

I've used Tomcat and JBoss a lot more, but from what I've seen GlassFish is pretty dang cool, like you said the admin console is just simpler to use and more robust. They're all fine really.

Zaphod42 fucked around with this message at 22:37 on Nov 6, 2013

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

fletcher posted:

I haven't used it before, but the Play Framework seems like a good way to hit the ground running.

Holy poo poo man Play Framework is the exact opposite of baby's first Java web, it's a huge framework of java, scala, sbt and plugins. It runs its own webserver instead of using the standard WAR packaging system, it's as far away from the standard java ecosystem as you can get.

Learn Servlets and JSPs first they are the building blocks that everything else is built on, then get into frameworks like Spring, Struts 2 or Wicket.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Hard NOP Life posted:

Holy poo poo man Play Framework is the exact opposite of baby's first Java web, it's a huge framework of java, scala, sbt and plugins. It runs its own webserver instead of using the standard WAR packaging system, it's as far away from the standard java ecosystem as you can get.

Learn Servlets and JSPs first they are the building blocks that everything else is built on, then get into frameworks like Spring, Struts 2 or Wicket.

Yeah you're right, probably not the best way to start out. From what I had heard about it it kinda sounded like Django for Java.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
Yeah Play is different in that it tries to break away from the Java EE system of requiring an application server to host your application by bundling it's own web stack. I'm convinced that the motivations for it amount to nothing more than "gently caress You Dad, our way is cooler!", but that just might be my YOSPOS leaking, either way it looks cool and I'll have to delve more deeply into in the near future.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

fletcher posted:

Yeah you're right, probably not the best way to start out. From what I had heard about it it kinda sounded like Django for Java.

Yeah its like Django or Rails for Java.

:barf:

PleasantDilemma
Dec 5, 2006

The Last Hope for Peace

Hard NOP Life posted:

Learn Servlets and JSPs first they are the building blocks that everything else is built on, then get into frameworks like Spring, Struts 2 or Wicket.

I'm gonna go with this. If anyone knows some good servlet/jsp tutorials feel free to post them. I'm gonna fire up Eclipse and see what google search can teach me.

Volguus
Mar 3, 2009

PlesantDilemma posted:

I'm gonna go with this. If anyone knows some good servlet/jsp tutorials feel free to post them. I'm gonna fire up Eclipse and see what google search can teach me.

Getting a book (i cannot recommend any, just pick one, if they got published they cannot say bullshit in there) may be a good idea also.

As for tutorials I would start with the reference one: http://docs.oracle.com/javase/tutorial/ and go from there.

Doctor w-rw-rw-
Jun 24, 2008

Hard NOP Life posted:

Yeah Play is different in that it tries to break away from the Java EE system of requiring an application server to host your application by bundling it's own web stack. I'm convinced that the motivations for it amount to nothing more than "gently caress You Dad, our way is cooler!", but that just might be my YOSPOS leaking, either way it looks cool and I'll have to delve more deeply into in the near future.

Play is based off of Netty, which is a particularly awesome asynchronous networking engine based on Java's NIO API (non blocking IO). Unlike node.js, Netty actually has threads and poo poo, and is very solid - I believe many hedge funds and some of the rest of the financial sector use it for realtime stuff.

To my recollection, Play also does fancy things with making requests isolated from each other, i.e. making even static variables thread-local so that requests can pause when they're blocked on IO and such and be resumed later with ease. It's not necessarily going to get more absolute throughput, but depending on the workload, responsiveness may improve on top of Play. They used to use ECJ (Eclipse's java compiler in library form) to compile code on demand, which they also manipulated the bytecode of, I think.

Woodsy Owl
Oct 27, 2004
I thought I understood try-catch blocks, but I'm thinking I don't fully get them after trying to implement my own. I know that try-catch blocks must surround such object calls such as instantiating a new FileInputStream or reading from the stream. In fact, if try-catch isn't present then Eclipse will refuse to compile. But ArrayList will throw an index out of bounds exception when necessary, but Eclipse doesn't seem to give two shits about not surrounding ArrayList calls with try-catch. Does that make sense at all?

So... when are try-catch blocks required by methods that throw exceptions and when are they not? I am trying to implement a data structure and I want to throw my own exceptions but I don't want users to have to use try-catch blocks.

Sorry if it's unclear what my question is. ArrayList throws exceptions at times, so does FileInputStream. But Eclipse won't complain about no try-catch block with ArrayList. What gives? Am I missing something glaringly obvious?

Also, Firefox wants to autocorrect FileInputStream to milkstream, ha!

Tamba
Apr 5, 2010

What you want are unchecked exceptions.
You might also want to read this before you actually decide to use them though: http://docs.oracle.com/javase/tutorial/essential/exceptions/runtime.html

Woodsy Owl
Oct 27, 2004

Tamba posted:

What you want are unchecked exceptions.
You might also want to read this before you actually decide to use them though: http://docs.oracle.com/javase/tutorial/essential/exceptions/runtime.html

Good deal, thanks for those. I learned a lot reading through, and now I have some good bookmarks. It looks like the data structures already provided in the standard library throw exceptions that inherit RuntimeException, which makes them unchecked.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

Woodsy Owl posted:

Good deal, thanks for those. I learned a lot reading through, and now I have some good bookmarks. It looks like the data structures already provided in the standard library throw exceptions that inherit RuntimeException, which makes them unchecked.

Yeah, exactly. Unchecked exceptions can be kinda confusing when you're learning exception handling for the first time. Runtime Exception for instance is supposed to be things that can't be predicted at compile-time, so its not worth making the compiler enforce them. Lots of time Runtime Exceptions mean things are so fubar you're just going to crash anyways and there's no real graceful way to handle it.

Also, (you probably already know this) you can always declare that your method throws the exceptions that the code it uses throws, and then it isn't responsible for having a try/catch block to handle those exceptions. Instead, if it gets an exception, it'll just pass it up the stack to the nearest calling method which DOES have a try/catch block to resolve the code. Lots of times this is actually the behavior you want. It depends upon what level of the code you're in and how intelligent / error correcting you want that code to be. So your Main function could call method A, which calls method B, and B throws an Exception. A doesn't try/catch it, it simply throws it up, so Main ends up catching the exception and prints out a handy error message to the user to let them know something went wrong (like their internet is disconnected).

Exceptions should be typed when possible, just saying catch(Exception e) all the time is bad practice.

Oh and don't ever loving write this:
code:
catch(Exception e){
}
Print the stack trace, print an error to system.out, do anything. But gobbling up exceptions without doing anything about them makes maintenance/debugging impossible. Better to just throw the exception than do this.
or this
code:
catch(Exception e){
    throw new Exception();
}
fuuuuuuck

Zaphod42 fucked around with this message at 21:11 on Nov 11, 2013

Woodsy Owl
Oct 27, 2004

Thanks loads mate, I really appreciate it!

Volguus
Mar 3, 2009

If you don't want to handle an exception in some parts of your code, it is almost always better to encapsulate it.

code:
catch(SomeExceptionFromSomewhere e){
    throw new MyWhateverOperationException("Cannot do work",e);
}
The main reason for that is so that particular code behaves like a library. You want to hide the details of your implementation, and one way to do that is to not let the other exceptions propagate. Except yours, if you have to. What do you get from that? The ability to change the details of your implementation. Maybe today you are using a library that throws XXException, but tomorrow another library that is throwing YYException. The users of your code (that includes your own application) shouldnt be affected.

pigdog
Apr 23, 2004

by Smythe
... but make sure you pass the original exception as cause, as in

code:
throw new MyWhateverOperationException("Cannot do work",e);
instead of just
code:
throw new MyWhateverOperationException("Cannot do work");
... since the latter hides the original cause of the exception and would be a horror to debug. Always add information when you throw your exception, never remove it.

Gravity Pike
Feb 8, 2009

I find this discussion incredibly bland and disinteresting.
The Guava Throwables library has a nifty convenience operation for this use case:

Java code:
try {
    myDangerousOperation();
} catch (Exception e) {
    Throwables.propagate(e);
}
which basically expands to:

Java code:
try {
    myDangerousOperation();
} catch (Exception e) {
    if (e instanceof RuntimeException) {
        throw e;
    } else {
        throw new RuntimeException(e);
    }
}

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Gravity Pike posted:

The Guava Throwables library has a nifty convenience operation for this use case:

Java code:
try {
    myDangerousOperation();
} catch (Exception e) {
    Throwables.propagate(e);
}
which basically expands to:

Java code:
try {
    myDangerousOperation();
} catch (Exception e) {
    if (e instanceof RuntimeException) {
        throw e;
    } else {
        throw new RuntimeException(e);
    }
}

I hate that. Spring does that poo poo of converting all exceptions into runtime, and it loving sucks. Say what you will about the merits of checked vs. unchecked exceptions, but there's a reason they exist, so that any calling code knows what it's dealing with.

Gravity Pike
Feb 8, 2009

I find this discussion incredibly bland and disinteresting.
I mean, absolutely, there is a science to propagating exceptions, and generally wrapping everything in a RuntimeException is the wrong thing to do. On the other hand, we have UnsupportedEncodingException. It is checked, and explicitly gives me a chance to react to it. Now, I'm asking for UTF-8. I know that I have access to UTF-8. It is utterly unreasonable to force everything at a higher level to deal with the possibility of an UnsupportedEncodingException. But it is also insanely unsafe to write code that would just swallow this exception, even though I know it'll never actually be thrown. So I wrap it in a RuntimeException, and get to ignore it, and still feel confident that the system isn't ignoring it, and it'll bubble up to a point where someone (the server framework, usually) will transform it into a useful response. (500 Server Error) (If you take issue with UnsupportedEncodingException in this instance, feel free to substitute NoSuchAlgorithmException.)

The law of the land is to propagate checked exceptions that calling code has a reasonable expectation of being able to recover from. If one of my arguments is the encoding, yeah, pass along that Exception so maybe my caller can ask for a different one. But if you just bubble up every possibly thrown exception in your method signature, you're preventing your users from seeing what is actually likely, and obscuring their options for recovering from any given exception.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
Of course, in cases where you *know* that you won't actually throw the checked exception (and there are many such cases), then do what you want. It just looked like you were advocating the Spring approach of wrapping *all* exceptions as runtime, which I still say loving sucks.

FateFree
Nov 14, 2003

Kilson posted:

Of course, in cases where you *know* that you won't actually throw the checked exception (and there are many such cases), then do what you want. It just looked like you were advocating the Spring approach of wrapping *all* exceptions as runtime, which I still say loving sucks.

What's wrong with having only runtime exceptions? Thats how new languages like c# handle exceptions. Checked exceptions have caused more pain and harm and general misuse than any other feature. All it takes is a @throws declaration in the comments and anyone whose calling your method can choose to handle a runtime exception or ignore it.

Max Facetime
Apr 18, 2009

FateFree posted:

What's wrong with having only runtime exceptions? Thats how new languages like c# handle exceptions. Checked exceptions have caused more pain and harm and general misuse than any other feature. All it takes is a @throws declaration in the comments and anyone whose calling your method can choose to handle a runtime exception or ignore it.

What's wrong is how this choice gets presented, or rather usually doesn't get presented. Even if I could trust a library author to always follow the @throws documentation convention, I'd still prefer to make the choice by answering one question:
  • Add throws declaration?
  • Surround with try/catch?
  • I'll do it myself.

Instead of having the correct documentation at hand, having it open, having it open in the right place, scanning the documentation for one particular keyword, then typing the code myself based on what I've chosen.

DholmbladRU
May 4, 2006
wrong thread..

DholmbladRU fucked around with this message at 20:18 on Nov 14, 2013

A Tartan Tory
Mar 26, 2010

You call that a shotgun?!
I don't suppose anyone could quickly tell me why my servlet that is generating a HTML image code isn't working? It's generating the first and last parts, but it's not generating the folder and I honestly have no idea why (I double checked all the sql) and eclipse is not informing me of any obvious errors. Thanks in advance!

quote:

Statement stmt2 = con.createStatement();
String query2;
ResultSet rs2;

// Asking for the Folder of the picture for image generation
query2 = "Select Folder FROM categories WHERE CategoryNo = "+category+"";
rs2 = stmt2.executeQuery(query2);
out.println("<img src=\"http://galleryurl/");
while (rs2.next()) {
String folder = rs2.getString("Folder");
out.println(""+folder+ "/");
}

Statement stmt3 = con.createStatement();
String query3;
ResultSet rs3;

// Asking for the Name of the picture for image generation
query3 = "Select FileName FROM pictures WHERE PictureNo = "+picture+"";
rs3 = stmt3.executeQuery(query3);
while (rs3.next()) {
String fileName = rs3.getString("FileName");
out.println(""+fileName+ "\">");
}

quote:

<img src="http://galleryurl/folder/BIGshot.bmp">

Is what it currently generates and the bolded is what is missing. It must be obvious but I just can't see it!

Or, the code itself might not be faulty, it just isn't remembering what 'category' is. :downs:

edit2: Solved.

A Tartan Tory fucked around with this message at 21:09 on Nov 14, 2013

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
Shouldn't mix database access and presentation like that. Also need to close your database resources when you're done with them using a try/catch/finally. Also don't use string concatenation to build SQL statements, use prepared statements instead to avoid SQL injection attacks.

A Tartan Tory
Mar 26, 2010

You call that a shotgun?!

fletcher posted:

Shouldn't mix database access and presentation like that. Also need to close your database resources when you're done with them using a try/catch/finally. Also don't use string concatenation to build SQL statements, use prepared statements instead to avoid SQL injection attacks.

This is just me loving around trying to learn the absolute basics, but thanks for the input! I did find out what wasn't working though and it was that I forgot to add in my session management in that servlet and therefore it had no loving idea what 'category' was.

Adbot
ADBOT LOVES YOU

A Tartan Tory
Mar 26, 2010

You call that a shotgun?!
Another small question if I can get away with double posting this once. I'm now trying to make a dynamically generated table using SQL and java by doing the following.

quote:

try {
Statement stmt = con.createStatement();
ResultSet rs;
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT statistics.accessdata, pictures.ShortName, categories.ShortName FROM jcg ORDER BY AccessCount");
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
int rowCount = 0;
while (rs.next()) {
out.println("Row " + (++rowCount) + ": ");
for (int i = 1; i <= numberOfColumns; i++) {
out.print(" Column " + i + ": ");
out.print(rsmd.getColumnLabel(i) + ": ");
out.println(rs.getString(i));
}
}

However, I have a feeling my SQL is balls, because I keep getting exceptions when trying to use statistics.accessdata, pictures.ShortName, categories.ShortName from my container jcg. Can anyone give me an example of an SQL query that would work in this situation, to call up accessdata and the two different shortnames and then create a table displaying them ordered by the accesscount integer?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply