This week's book giveaways are in the Scala and Android forums.
We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!

Marsoni Hutao

Greenhorn
+ Follow
since Jun 18, 2015
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Marsoni Hutao

Dave Tolls wrote:
I would check your logs.



Here is my log output

java.lang.NullPointerException
        at sun.jdbc.odbc.JdbcOdbcDriver.initialize(JdbcOdbcDriver.java:453)
        at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:153)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at Src.Files.TestExcel.TestMyExcel(TestExcel.java:51)
        at Src.Files.ReportsGeneratorGUI$3.actionPerformed(ReportsGeneratorGUI.j
ava:93)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
ce)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$500(U

Dave Tolls wrote:myConn will never be null.
It cannot.
If getConnection fails it will throw an exception.



Thanks for that quick point 

I would check your logs.



where can I find them in the target system? 


Messages: Column count doesn't match value count at row 1


In your table, there are 2 columns (id, item_no), and you are inserting only one value. Is the other a primary key? if so, you are missing the basic thumb rule of PK,

Should be unique and not null

.

But here you are not inserting second or first value to DB, which means it will be taking a null.
for debugging I've added the below code in the file.


When I run this in my machine, I get

JDBC ODBC Driver Registered!
You made it, take control your database now!



When I do the same on the second machine, it gives

JDBC ODBC Driver Registered!



But not returning the connection status. 
Hi,

I'm writing a Java Swing app in Eclipse. I've exported as a runnable jar. And when I run it. Everything is working fine. So I've sent the same JAR to my second machine. And When I ran it, to my Surprise, this therw a null pointer Exception.

Below is a piece of my code.


This is working fine on my Machine, But in my second machine it is throwing the exception in the below line.


Please let me know where Am I going wrong and how Can I fix this.

Here I'm not getting Exception on my machine, it is getting thrown on another machine, I would have debugged if the issue was on my Machine.

Here is my stack trace

java.lang.NullPointerException at sun.jdbc.odbc.JdbcOdbcDriver.initialize(JdbcOdbcDriver.java:453) at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:153) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at Src.Files.TestExcel.(TestExcel.java:39) at Src.Files.ReportsGeneratorGUI$3.actionPerformed(ReportsGeneratorGUI.java:91) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)


Thanks

Campbell Ritchie wrote:Yes.



Sorry for the delayed reply. Thank you soo much. This worked for me

For those who have similar problem, here is the solution.


Cheers
2 years ago

Campbell Ritchie wrote:But file5523.100 is always before file5523.3.
If you want the files to be sorted by the numeric value of the extension rather than by their names, you will have to write a Comparator for the two parts of the file nam.



You mean that I've to consider filename after the period?
2 years ago
Hi,

I'm writing a code where in there a bunch of files that have to be taken as input from a directory.

The program works fine, but the problem comes up in the way the files are picked. In my directory when I do a sort the first file shown is file5521.3, but in my program the first file that is picked up is file5521.100. THis is pretty confusing.

I've also tried using Arrays.sort(list, NameFileComparator.NAME_COMPARATOR), but it also gives the same result as previous.

Below is my code.


please let me know how can I do this.

Working Solution with Last Modified Date


The Comparator works fine with last modified date, but when I try it with below code. The result is same as previous.




In my Windows Explorer It looks like the Windows Image.


And my console output shows Console Image.

I'm using Windows 7.

Thanks,
Marsoni
2 years ago
Hi,

I'm writing a program where there is a table to be created when ever there id a date change. But the problem here, first the table gets created on selecting date, But when i start changing the date the table doesn't get created, and there are no errors in the console. Below are my codes.

table.jsp



tableGenerator.js



Controller



DataDAO.java



please let me know how can i do this. I should get the data without refreshing the page. i.e. As soon as i change the date, the changes should be reflecting. When I saw in developer options in Chrome, it is the same JSON response. I mean there is no error or such thing, json data is displayed in the log.

The problems come up only there is a change in date. The data doesn't get displayed, But the data is reflected in Console.

Thanks,
Marsoni
Hi,

I've a jsp that get the sum from a database. and i want to show this on every webpage the user opens in header. Here totally there are 8 pages, right from the time the index page is opened, let it be any page the user opens, the header should be fixed. My current code is as below.

Index.jsp




and my Servlet is as below



Here everything is working fine. But the problem comes up with when i have multiple pages

I need the same above mentioned header in all the files. If i use a separate file and use a <jsp:include file/>, the entire page gets reloaded as a new page and shows the contents of new page.

Below example will give a better understanding.

I've 2 pages Index, counts these are JSPs.

There is some content in both index page, and the counts page is responsible for displaying counts (in the header) and it done in js using onload method.

When i run my program. The Index page is shown with its content and there would be a redirect to the counts.jsp and the content of counts.jsp is shown as a seperate jsp file, and the contents of index will be missing.

please let me know how can i do it. I want the result to be displayed in the header section itself without missing the body content.

A simple comparison would be with the frames that we use earlier. When we have a frame in header, what ever operations are done will be done there itself, it won't affect the entire age.

Thanks
2 years ago
JSP
Hi,

I'm making a webpage, where in there is a dropdown and I select that value and hit click.

There is a javascript function containing some variables with the same ID as that of the dropdown values(option id). And there is an array of the same variables declared. Once I hit the click button i want the value that is selected in the dropdown, to be matched with the variable in variable array created and alert the same.

Currently it is not alerting any, if i add an else block, that gets triggered. Below is my JS.


And here is my full code in fiddle.

JSFiddle

please let me know how can i compare and get the correct result in the alert box.

Further i need to create a dynamic table here based on the data.

Thanks,
Marsoni

does an Excel file allow you to have multiple JDBC connections into it at the same time?



You can use a DNSLESS connection, only one connection at a time.

Firstly, Thank you for Introducing me to this new concept.

Here is a document on using pooling with SQLServer. Actually setting up the pool depends on what web server you are running.



In my webapp, I've 2 different connections, one is incoming i.e. from where the input data comes and the other is outgoing, i.e. where the data is sent to.

I've mentioned these as two different one as the incoming comes from an excel and the outgoing is to SqlServer.

My Question is can I have multiple connection pooling, i.e. one for excel and other for SqlServer.

If you are the server admin and need guidance on setting up the pool, we have other forums where you can get help with the specifics.



Can you please provide me a link to this.

Thanks,
Marsoni
Hi Kevin,

Thanks for this suggestion.

J. Kevin Robbins wrote:You are off to a good start. Your code looks well organized. There is room for improvement, especially in your DBUtility class, but we can talk about that later if you wish.



Yes Please, I would love to know the flaws/improvement suggestions.

JI do a lot of pages like this, and I use a jQuery plugin called [url=http://datatables.net/ wrote:DataTables[/url]. It's made for this very scenario. It will take your Ajax response and turn it into a table with pagination, search, sorting, etc. It's easy to get started with, but complex to master. But it's worth it. I use it a lot.




Went through this. And this is very helpful. But I've some question. I'll better post it separately.

Thanks,
Marsoni

2 years ago
JSP