124 Replies
⌛
This post has been reserved for your question.
Hey @Mookha! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.

1
userID (is discord id)
PlayerName (is the player name in minecraft with a name length from 3 to 16 characters)
Cooldown (is an 11-digit timestamp)
2
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
How are you inserting/deleting stuff?
if you have multiple
INSERT INTO
statements with the same content, it may fail/throw an exception if it violates constraints
or you might have multiple rows if it doesn't violate constraints (e.g. you use AUTOINCREMENT for the primary key and no relevant unique constraints)
If you have multiple DELETE FROM
statements that delete the same data, the later ones would just finished with "0 rows modified"are never the same in value
?
What about it?
Insert
what about it?
If the
userID
is the primary key, you won't be able to insert rows with the same ID multiple times
doing it the second time will give you an SQLException
ya discord ID is not duplicated
Then what's the question?
I mean many users do and many insertusers will be sent
I add index for playername and wal on
if you do that twice with the same user ID, nothing from the second INSERT will be inserted
If you want to ensure the player name is unique, you can use a UNIQUE constraint in the schema
will not be possible with the same user
Then what exactly is happening that you don't want to happen?
As far as I know, you can only insert it once, not at the same time
yes
So What happens if 2 users do it at the same time?
With the same user ID?
No that different
then it would insert both
Will it not be ignored??
Shouldn't it only be inserted once in a period of time?
Why?
Why should it ignore anything?
it will lock and insert will be rejected, maybe it will put it on the waiting list?
Why would SQL lock anything?
Normally databases want to process as many requests as possible
I thought it would be locked when recording to secure the data
the DB makes sure that there are no data corruptions
so it might insert rows after each other if two requests are coming in at the same time or use other mechanisms to protect against that
but it does allow you to insert multiple things at the same time
I don't really understand what a .comic is, is it necessary?
the DB makes sure that statements (or transactions) are either fully executed or not at all
you mean atomic?
That is Synchronize?
?
setAutoCommit
connection.commit()
Idk @@
What do you want to know about committing?
Yea
I ask you "what do you want to know about" and you answer with "yes". How should I interpret that?
i don't know how it works, new database with
How what works?
commits/transactions?
Sqlite
Idk that
There are many things about sqlite
What is this?
Transactions?
I don't understand why someone said I should have a commic
List +for
The database really has so much to learn
Databases have a concept of transactions. A transaction is started, then you can use as many SQL statements as you want and then you can commit the transaction. The DB then makes sure that the SQL statements only apply when you commit it. If you don't commit it, these won't be executed. If you rollback a transaction, it will revert everything that happened in that transaction. This makes sure that if you do two things together, you don't end up in an in-between state where one part has been executed and the other part hasn't.
There is no "a commic" but there is the concept of "atomicity" or "atomic"
atomic means "It's either completely executed or not at all" - you won't get partial executions. This is what I just said about transactions. They are either committed or rolled back but not partially executed
Is it like multi insert?
?
.
If you include multiple INSERTs in a single transaction, then these will be atomic meaning that you won't end up in a state where some are executed and others aren't
autocommit means that every statement is automatically committed/every statement is its own transaction
In short, my previous insert needs to add anything, should I use asynchronous + wal?
?
I have no idea what you are talking about
Sorry
.
I still have no idea what you mean with asynchronous + wal
inherently synchronous is the default, but would asynchronous be better in terms of performance?
Not necessarily
The language gap left me quite helpless
it depends
Do you mean having to talk English?
Depend?
I mean I'm not good at English, I'm only good at Chinese and Vietnamese
What would you like to be doing asynchronously?
I don't know if using it will be better, I see it has the risk of losing data
.
Will this code not have problems if called at the same time?
If it isn't using the same
connection
, noI'm afraid it's the same...
So....
Do you have a good plan?
For some DBs,
Connection
s are thread safe/safe to use concurrently
In other cases, you could use a connection pool?
it makes me very confused
If the JDBC driver doesn't have thread-safe connections
there are multiple different types of databases
According to the SQLite docs, you shouldn't use the same
Connection
in a multithreaded environment
https://www2.sqlite.org/cvstrac/wiki?p=MultiThreadingBut now what to do about the connection problem?
you can create multiple
Connection
s?
and e.g. give one to each thread that does DB accessWhqat
or use a connection pool
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Queues will slow down, but it's not as important as data being guaranteed
Is it okay if I do this?
What kind of queue are you talking about?
If you just want the DB operations to be executed after each other, you can use
synchronize
lock and unlock
yeah you can do that
So which functions are considered multi-threaded?
or you just have one
Connection
for each important thread (but make sure you are closing these connections when necessary)
?
synchronized is just lockingmeaning call the function and the function will be postponed until it completes then it will continue to the next request?
yes
Is it considered multi-threaded?
JDA uses a single thread for its listeners
and will it have to wait if there are 2 requests at the same time?
synchronize is better ?
not necessarily
yes, that's what JDA does
...
Please answer these 3 small questions
1.Is lock different from synchronize in any important way?
2. "ensureOffThread(false);" What is this, is it necessary?
java.util.concurrent.Lock
gives you more control and there are different types of Lock
s
idk where you got that from
that isn't a JDK thingThis message has been formatted automatically. You can disable this using
/preferences
.here
How to avoid main thread?
This seems to result in warnings when being used from outside the main thread
maybe it's not necessary
I think they just don't want to block the main thread
which seems very necessary if you don't want an unresponsive application
3.
Is it okay?
It might be a good idea to also roll back in case of a
RuntimeException
and just rethrow it in that caseWell, for example, there are people who are crazy about spam and force it to be filtered constantly. Do you have a good way to solve this problem?
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
?
spam get info user
what, idont understand...
So what's the problem with that
1 user get username or cooldown
If something bad happens in the
Runnable
, you might want to execute connection.rollback()
Also in case of an SQLException
what ?
that
Runnable
hereCan you get a sample? It sounds so confusing to me
If it throws a
RuntimeException
, what should happen with the data?error? or dupe?
yeah but should the DB still be changed?
Do you mean calling it again to insert it into insert?
If you run
connection.rollback();
, it makes sure it isn't executed
something like that
oh ty
Did I just put the callback in the wrong place???
?
whether you use synchronized or locks doesn't matter that much
i mean rollback
yeah you can do that as well
what
Yes, but things that might be okay should be left alone @@
If a person needs to get their info id and they spam requests continuously through commands or buttons, causing select to be called continuously, what should they do? Save it in cache?
you can make a rate limit per user?
Here's an example: What if it's a 1-player connection to the server?
Minecraft
I have no idea what you are talking about
but I have no diea about Minecraft development
Why u use "try" in" try"
so that the connection can be rolled back in case of both a
RuntimeException
and SQLException
If I delete the external catch, is there any problem?
you'd need to move the
handleSQLException(e)
yae it only sends when there is an error
Finally, I was able to leave the database dynamic, thank you so much
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Post Closed
This post has been closed by <@1252543231233622110>.