uuid

Read MySQL binary(16) UUID with Java

喜你入骨 提交于 2019-12-06 05:11:02
问题 This should be a very simple question, I'm just missing something basic here and I'm having 'one of those days...' Cannot use Hibernate or other ORM. Using Java PreparedStatement. MySQL stuff: CREATE TABLE `article` ( `articleID` binary(16) NOT NULL, `publisherID` bigint(20) DEFAULT NULL, PRIMARY KEY (`articleID`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8$$ insert into article ( articleID, publisherID ) values ( (UNHEX(REPLACE(UUID(),'-',''))), 1111 ); Java stuff PreparedStatement ps = connection

uuid模块

↘锁芯ラ 提交于 2019-12-06 03:36:30
  UUID即通用唯一标识符,对于所有的UUID它可以保证在空间和时间上的唯一性。它是通过MAC地址、时间戳、命名空间、随机数、伪随机数来保证生成ID的唯一性,有着固定的大小(128 bit)。它的唯一性和一致性特点使得可以无需注册过程就能够产生一个新的UUID。UUID可以被用作多种用途,可以用来短时间内标记一个对象,也可以辨别网络中的持久性对象。   python中uuid模块提供UUID类和函数uuid1()、uuid3()、uuid4()、uuid5()来生成各个版本的UUID。   1. uuid.uuid1([node[, clock_seq]]):基于时间戳   使用主机ID,序列号,和当前时间来生成UUID,可保证全球范围的唯一性。但由于使用该方法生成的UUID中包含有主机的网络地址,因此可能危及隐私, 不安全。   该函数有两个参数,如果node参数未指定,系统将会自动调用getnode()函数来获取主机的硬件地址。如果clock_seq参数未指定系统会使用一个随机产生的14位序列号来代替。   2. uuid.uuid3(namespace, name):基于名字的MD5散列值   通过计算命名空间和名字的MD5散列值来生成UUID,可以保证同一命名空间中不同名字的唯一性和不同命名空间的唯一性,但同一命名空间的同一名字生成的UUID相同。   3. uuid

mysql_insert_id or something like that to return last mysql UUID()

狂风中的少年 提交于 2019-12-06 03:34:31
How do you return the last generated UUID() (primary key) - is there something like mysql_insert_id for that? Table uuidtable : primary key: uuid uuid() id_u (index): integer multiple id_u matched with a primary key uuid() insert: insert into uuidtable (uuid,id_u) values (uuid(),id) where id is a number, of course, and uuid is escaped with uuid Write yourself a trigger like so: CREATE TRIGGER ai_uuidtable AFTER INSERT ON uuidtable FOR EACH ROW SET @last_uuid = NEW.uuid; Following an insert: SELECT @last_uuid MySQL's user-defined variables are connection-specific, so you don't have to worry

How do I insert a row with a TimeUUIDType column in Cassandra?

喜夏-厌秋 提交于 2019-12-06 03:26:19
问题 In Cassandra, I have the following Column Family: <ColumnFamily CompareWith="TimeUUIDType" Name="Posts"/> I'm trying to insert a record into it as follows using a C++ generated function generated by Thrift: ColumnPath new_col; new_col.__isset.column = true; /* this is required! */ new_col.column_family.assign("Posts"); new_col.super_column.assign(""); new_col.column.assign("1968ec4a-2a73-11df-9aca-00012e27a270"); client.insert("Keyspace1", "somekey", new_col, "Random Value", 1234, ONE);

what is the best way to use the C type uuid_t as a key in a std::map?

对着背影说爱祢 提交于 2019-12-06 02:46:32
问题 Is this an appropriate way to provide unique keys in a map? In other words, is the key being made from the unique value contained in the uuid, or is it being made from the pointer to the uuid_t struct? A side question, is there a more efficient container, when I don't care about the ordering by keys inside the container? #include <uuid/uuid.h> int main(int argc, char **argv) { std::map<uuid_t,int> myMap; uuid_t id1; uuid_t id2; uuid_generate( (unsigned char *)&id1 ); uuid_generate( (unsigned

Is it safe to turn a UUID into a short code? (only use first 8 chars)

我的梦境 提交于 2019-12-06 02:17:32
问题 We use UUIDs for our primary keys in our db (generated by php, stored in mysql). The problem is that when someone wants to edit something or view their profile, they have this huge, scary, ugly uuid string at the end of the url. (edit?id=.....) Would it be safe (read: still unique) if we only used the first 8 characters, everything before the first hyphen? If it is NOT safe, is there some way to translate it into something else shorter for use in the url that could be translated back into the

E-mail verification with keys made with uuid.uuid4. Safety, and uniquness of generated values [closed]

心不动则不痛 提交于 2019-12-06 00:29:29
Closed . This question needs to be more focused . It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post . Closed 5 years ago . I would like to make e-mail verification in my website. I plane to send to user email with link to activation, where in link I plan to include key made with: str(uuid.uuid4()) which will be stored in table, where I also will store boolean indicating either user has used this link (activated the account) and the date which will stand for time when key expires. My questions: is it

UUID bluetooth and android devices

旧街凉风 提交于 2019-12-06 00:16:32
I'm trying to develop an application for Android devices that connects two devices, but the problem is that I can only connect (using Bluetooth) with PC Bluetooth or devices with another OS than Android. I think that the problem is the UUID, right now I'm using, in BluetoothCommandService.java : private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); And then: private class ConnectThread extends Thread { private final BluetoothSocket mmSocket; private final BluetoothDevice mmDevice; public ConnectThread(BluetoothDevice device) { mmDevice = device;

Unique Linux filename, sortable by time

≡放荡痞女 提交于 2019-12-06 00:08:08
Previously I was using uuidgen to create unique filenames that I then need to iterate over by date/time via a bash script. I've since found that simply looping over said files via 'ls -l' will not suffice because evidently I can only trust the OS to keep timestamp resolution in seconds (nonoseconds is all zero when viewing files via stat on this particular filesystem and kernel) So I then though maybe I could just use something like date +%s%N for my filename. This will print the seconds since 1970 followed by the current nanoseconds. I'm possibly over-engineering this at this point, but these

Probability of collision of SecureRandom.urlsafe_base64(8) in Ruby?

回眸只為那壹抹淺笑 提交于 2019-12-05 23:57:35
I am using SecureRandom.urlsafe_base64(8) in order to create unique ids in my system that are URL safe. I would like to know how to calculate the probability of collision? I am inserting about 10.000 of those ids into an array, and I want to avoid checking if one of the keys is already in the array, but I also want to make sure that are not repeated? What are the chances? Andrew says Reinstate Monica There is a good approximation of this probability (which relates to the birthday problem ). If there are k potential values and n are sampled, the probability of collision is: k! / (k^n * (k - n)!