Castiel Snow

Ranch Hand
+ Follow
since Aug 06, 2019
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
14
Given in last 30 days
7
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Castiel Snow

Tim Holloway wrote:Apparently buildSessionFactory() was deprecated as far back as 2011. That's 10 years of software erosion there.

It's also, I assume, part of legacy Hibernate, not Hibernate JPA, and I've been recommending that people migrate to JPA for many years now.

It's not true that you can write software and it "never wears out". The software may remain unchanged, but the world that contains it does not, and eventually, not only is it more and more likely to fail in time and  there will be fewer and fewer people who can help.

And, alas, I'm not one of them.



Wow
I didnt know that!

How do I migrate to JPA? How do I start?
Im googling.. seems I can convert my actual code.

Something like this should work?



https://stackoverflow.com/questions/8640619/hibernate-serviceregistrybuilder


Or even this? https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/3-ways-to-build-a-Hibernate-SessionFactory-in-Java-by-example
How to Optimize Hibernate buildSessionFactory();"


Im trying to optimize my hibernate initialization.
'cfg.buildSessionFactory();' consumes a lot of CPU. And on low-end systems is taking more than 20 seconds.
Is there anyway I can cache it and just load manually?

Im stuck. I cant find a way to optimize this. Whats the proper way to
make 'cfg.buildSessionFactory();' faster?





**Additional Information:**

----
    compile group: 'org.hibernate', name: 'hibernate-c3p0', version: '5.4.27.Final'
----

Mapping xml file: (I redacted private information as REDACTED)




**References**

https://forum.hibernate.org/viewtopic.php?p=2242766

https://developer.jboss.org/thread/197521

https://github.com/spring-projects/spring-framework/issues/18305

https://docs.jboss.org/hibernate/orm/5.2/topical/html_single/bytecode/BytecodeEnhancement.html

Campbell Ritchie wrote:Please don't update an old post like that. Users will not notice the update after they have replied. I have reverted the edit. Please post a new post with the additional information.



Sorry, I thought was best to not pollute it. But I understand. Sorry.
Good thing I had a copy of this. Would be a pain to write all over lol

Im converting a DesktopApp(JavaFx) to a WebApp (Spring Boot).

The DesktopApp has a field called 'hyperlink', which is a String field. The User utilizes the JFileChooser to pick a file or even a folder and save the ABSOLUTE PATH to this file on the field called hyperlink. The user can also manually set the field and for example, set a internet URL (for example, a dropbox link with public access).

This field is then saved in the database.

Other users can then try to access this file. It usually works because users save the absolute path of the local network or even Internet URL's like 'https://redacted.something.com/file.txt.

In this case, a user could open the app, find this 'hyperlink' field and click open --> If its a URL, it will open a browser page. If its a network file, it will open explorer.exe on the absolute path given by the field.

However, this functionality must now exist on the spring boot version.

Problem

Was unknown to me that Browser's security forbid you to access local files. So now, I can neither get the absolute path with the HTML file chooser or access a local file with it.

How should I deal with this?

Someone mentioned me I should think about using either an extension in browser OR a java plugin (ew?).

Bear Bibeault wrote:No. Security concerns prevent the browser from having such access to the file system.



Is there anyway to bypass that?
Extensions?
Java apps?
Anything?
Im using SpringBoot
Is there local file manipulation that's been done with JavaScript that can actually get the absolute path to a file or folder when the user chooses with a directory or file picker?

Specifically, I'd like to read/show the ABSOLUTE PATH from a file and open the file if the user requests it. At this point I'm not worried about gaining permissions and am just assuming I already have full permissions to these files.
Thymeleaf - How to send a table as a list?

Greetings codeRanch. Hope you are all having a great end of 2020*.
I need help on how to solve a situation...

--Context--
I have a javafx Desktop Application. Im building now the Web version of this app.
I have a class called Tool, and it has the variable Collection<DistributionPoint> distributionPoints;
Im working on a page to add/update a Tool, like in the javafx app.



--Problem--
I have a combobox a Option/Combobox in my HTML that is filled with objects from the class "DistributionPoint" to pick from.
The user, can pick any they want and add to a table as long as its not added already in the table already (Doesnt allow repeated values).



From the UI side, everything works as it should.
When I press Save/Submit, it doesnt save the table as the distributionPoint list of 'tool'.
I've tried several things but none of them worked. Any tip on how to deal with this?



HTML file







4 weeks ago
Problem

Stuck on implementing change of schema after user login, following a StackOverFlow.

Description


Im following the stackoverflow solution at: https://stackoverflow.com/questions/39357367/change-database-schema-during-runtime-based-on-logged-in-user

The spring version im using is: :

   : Spring Boot ::        (v2.3.3.RELEASE)




I've created the class below. But I have no idea on how to use it properly.

What im trying to achieve is:

Springboot initializes in a default login database URL.
After login, it should use the class below to define which schema it should use based on the UserDetails class.

Im stuck. Im reading every tutorial, book I can find but im stuck. Please helpp







2 months ago
Hi!
I came up with a partial solution.

What Im planning to do is:

-Connect the spring boot directly to the login schema.
-Set up spring boot to use my custom User class.

-Login

-Change schema based on the login information.

--
Im a bit stuck on this part:
-Change schema based on the login information.

I found some information regarding people wanting to use 2 or 3 databases but in my case, it could be 'n' schemas GLOBALLY depending on which user log-in.






2 months ago
I have a message to my past self:

You can use Platform.isFxApplicationThread() to check if you are working on the UI thread or not.
You dont need or shouldnt  use Platform.runLater if you are already inside a UI thread.



https://docs.oracle.com/javase/8/javafx/api/javafx/application/Platform.html

You can use:

String s = Platform.isFxApplicationThread() ? "UI Thread" : "Background Thread";
System.out.println(s);

Inside a thread to find out whats going on.

Also, note that, when you are inside the @FXML initialize() method, you are in a UI thread. Which can be confirmed by the method above.


3 months ago
Question
How do I set up a custom login with Spring Boot? I need to use the same connection method of a legacy app I have.




Things to know before I explain

-I have a javafx App that connects to a data base using a php website as proxy/Login
-Obviously, this javafx app has the User class already defined.
-The javafx  application logs in with the web service and retrieves the database URL.
-The javafx  application uses the database URL to access a database directly.

Or, to simplify: The user put the login and password and click LOGIN -> The app,  goes to the webhost, sends the data to a certain php file and requests the database url and data that comes ENCRYPTED through JASPYR and it also comes through https. Once the data is returned, we decrypt it and login to the database directly.


-Im building a SpringBoot application to work with this legacy app.


Where Am I stuck?

I have built a Spring boot maven project and im reading a lot about Spring boot. My first step is to create a login page that behaves as the legacy app.

Currently, Im using a InMemorySecurityConfig as follows:




I dont know how to start. I think I have to find away to define the correct User model and then use a class to login that actually allows me to manually login.




Here is the legacy class that I use on my javafx App below. How do I start to convert this to spring boot? Please help.







How do I start? Any tips on how to start is greatly appreciated.

Im expecting that I have to somehow tell spring boot which User class to use, to tell spring to NOT instantly connect to the database and wait for the database info to be retrieved by the login page, and a way to login using spring.




The following topic explains my login process: https://coderanch.com/t/731125/engineering/Encrypt-JAVA-jasypt-Decrypt-PHP


PS: If the topic is not clear, please let me know. English isnt my first language but im trying my best.
#ThisForumRocks



References:
https://coderanch.com/t/735809/frameworks/User-Authentication-Authorization-Spring-Boot

https://spring.io/guides/gs/securing-web/

https://coderanch.com/t/734572/databases/Changing-database-DNS-Cname-adjustment
3 months ago
Problem/Question

"Application developers need to update their connection strings to point to the new server, and your customers need to know the new server address as well."

I have a desktop software. This java software has the following logic:

1-User inserts username and password. He presses "login" button.The data is then sent to a web server for validation.

2-In case of success, a JSON is sent back to the java app with the database url, username, password and most importantly THE SCHEMA etc. Note that, while the server IP is normally the same, the schema changes, thats why the JSON sents the correct schema URL for the client.

3-The java app then uses information from the JSON to connect to the MySQL directly.

Thats how it works. However, Theres a problem:
When the software was installed, I had to ask the IT of a few companies  to make sure the mysql address, which is typically the same, to be allowed through the firewall.
And now, we are currently in need of changing our current database from Hosting X to Hosting Y.

So basically it falls to this:
If I want to move a database from one server to another, or stand up a new server and move everything over to it, I will have to ask each IT to allow the new IP on their firewalls.


Proposed Solution

Researching, Ive come up with a solution. Im not sure its valid So thats why I came here in the first place heh.

So here's the thing.

On step 2, described above, the JSON sends the database URL like this:

jdbc:mysql://192.X.X.X:3306/ACME_SCHEMA1

Where X was a number but Ive just redacted for the topic.

The solution is, for the JSON to deliver this instead:


jdbc:mysql://db.acme.com.br:3306/ACME_SCHEMA1


By doing that, I can change the Register of db.acme.com.br from hg.acme.com.br TO aws.acme.com.br.

And I can just ask every IT to allow db.acme.com.br in their firewalls. So whenever I change databases, their firewall wont disrupt the connection.

Will this work? I know its not perfect but im working with a Legacy software so the structure has to make do.

Thanks a lot!






References:


https://www.techrepublic.com/blog/data-center/use-the-dns-cname-for-database-connectivity/

https://port1433.com/2016/08/03/using-dns-aliases-to-manage-database-connections/

https://coderanch.com/t/731125/engineering/Encrypt-JAVA-jasypt-Decrypt-PHP
For my own use. But I also want to give back to the community.
7 months ago
Hello everyone,

I made a topic some hours ago that lead me to a public repository : https://github.com/biezhi/webp-io

However, I had to update the library used, cwebp and make changes to the code.
Since its my first public fork, I want it to be good enough so others can use it as well. I think its good to give back to the community.

My fork is located here: https://github.com/KenobySky/webp-io

I have questions and any help would  be appreciated. Critiques too.

1- Do I have to update POM with my data?
2- What other changes to the project, not code-related do I have to make?
3- When I try to include the project with gradle, I get a weird error:



Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
  > Could not find com.github.KenobySky:webp-io:master.
    Searched in the following locations:
      - https://repo.maven.apache.org/maven2/com/github/KenobySky/webp-io/master/webp-io-master.pom
    If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
    Required by:
        project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org



Thanks a lot.
7 months ago
I will report back once I get this feature rolling.
Hopefully will help others.
7 months ago

Tim Holloway wrote:Tone down the boldface a little. It makes it look like you are shouting. Your spacing is all that's needed to make your points visible.

You forgot a very common solution, which is to upload the images to an ordinary image file directory. So there's a third solution.

Although I should caution you that if you do that, don't upload into a directory within your WAR or your webapp server. That can fail or cause data to get lost when you update the WAR. Always upload to an external data directory. In Unix/Linux, the /var/lib directories are commonly used for purposes like that. For maximum flexibility, however, don't hard-code the upload directory path into the webapp logic. Put it in a webapp environment object so that you can set it when the app is deployed and the app can read it using JNDI.

As for S3, that's fine if you want to store images in the cloud. I'd say that storing images as BLOBs in a database would be last choice.



Alrighty. I tend to do that because well.. a known moose competitor forces users to write very styled texts or they downvote you hehe.

But, I cant store locally. Its Not possible due to restrictions.

Im looking into converting every image to webp with https://developers.google.com/speed/webp/download.

Ive just forked this https://github.com/biezhi/webp-io

Ive updated with the new binaries and im going to commit to my fork.







7 months ago