package com.jms;import java.util.Map;import java.util.concurrent.ConcurrentHashMap;import javax.jms.BytesMessage;import javax.jms.Connection;import javax.jms.ConnectionFactory;import javax.jms.Destination;import javax.jms.JMSException;impo
package com.jms; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; import org.clapper.util.logging.Logger; import com.pzoom.dsa.common.util.Log; import com.pzoom.dsa.nerd.mysql.DBQueryHelper; public class Jms { static ConnectionFactory connectionFactory; static Connection connection = null; static Session session; static Map<String, MessageProducer> sendQueues = new ConcurrentHashMap<String, MessageProducer>(); static Map<String, MessageConsumer> getQueues = new ConcurrentHashMap<String, MessageConsumer>(); static Log log=Log.getLogger(DBQueryHelper.class); static { connectionFactory = new ActiveMQConnectionFactory( ActiveMQConnection.DEFAULT_USER, ActiveMQConnection.DEFAULT_PASSWORD, "tcp://10.100.100.100:61616?wireFormat.maxInactivityDuration=0"); try { connection = connectionFactory.createConnection(); connection.start(); session = connection.createSession(Boolean.FALSE.booleanValue(), 1); } catch (Exception e) { e.printStackTrace(); } } static MessageProducer getMessageProducer(String name) { if (sendQueues.containsKey(name)) return ((MessageProducer)sendQueues.get(name)); try { Destination destination = session.createQueue(name); MessageProducer producer = session.createProducer(destination); sendQueues.put(name, producer); return producer; } catch (JMSException e) { e.printStackTrace(); } return ((MessageProducer)sendQueues.get(name)); } static MessageConsumer getMessageConsumer(String name) { if (getQueues.containsKey(name)) return ((MessageConsumer)getQueues.get(name)); try { Destination destination = session.createQueue(name); MessageConsumer consumer = session.createConsumer(destination); getQueues.put(name, consumer); return consumer; } catch (JMSException e) { e.printStackTrace(); } return ((MessageConsumer)getQueues.get(name)); } public static void sendMessage(String queue, String text) { try { TextMessage message = session.createTextMessage(text); getMessageProducer(queue).send(message); // log.info("sendMessage " + queue + "\t\t" + text); } catch (JMSException e) { e.printStackTrace(); } } public static String getMessage(String queue) { try { TextMessage message = (TextMessage)getMessageConsumer(queue).receive(10000L); if (message != null) return message.getText(); } catch (JMSException e) { e.printStackTrace(); } return null; } public static void close() { try { session.close(); } catch (JMSException e) { e.printStackTrace(); } try { connection.close(); } catch (JMSException e) { e.printStackTrace(); } } }

mySqlStringTypesimpactStorageAndPerformanCeaseAsfollows:1)长度,始终使用theSamestoragespace,whatcanbefasterbutlessspace-felfficity.2)varCharisvariable varcharisvariable length,morespace-morespace-morespace-effficitybuteftife buteftife butfority butfority textifforlyslower.3)

mySqlStringTypesIncludeVarChar,文本,char,enum和set.1)varCharisVersAtileForvariable-lengthStringStringSuptOptoPeptoPepecifientlimit.2)textisidealforlargetStortStorStoverStorextorewiteWithoutAdefinedLengthl.3)charlisfixed-Length

MySQLoffersvariousstringdatatypes:1)CHARforfixed-lengthstrings,2)VARCHARforvariable-lengthtext,3)BINARYandVARBINARYforbinarydata,4)BLOBandTEXTforlargedata,and5)ENUMandSETforcontrolledinput.Eachtypehasspecificusesandperformancecharacteristics,sochoose

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

toadduserInmysqleffectection andsecrely,theTheSepsps:1)USEtheCreateuserStattoDaneWuser,指定thehostandastrongpassword.2)GrantNectalRevileSaryPrivilegesSustate,usiveleanttatement,AdheringTotheTeprinciplelastPrevilegege.3)

toaddanewuserwithcomplexpermissionsinmysql,loldtheSesteps:1)创建eTheEserWithCreateuser'newuser'newuser'@''localhost'Indedify'pa ssword';。2)GrantreadAccesstoalltablesin'mydatabase'withGrantSelectOnMyDatabase.to'newuser'@'localhost';。3)GrantWriteAccessto'

MySQL中的字符串数据类型包括CHAR、VARCHAR、BINARY、VARBINARY、BLOB、TEXT,排序规则(Collations)决定了字符串的比较和排序方式。1.CHAR适合固定长度字符串,VARCHAR适合可变长度字符串。2.BINARY和VARBINARY用于二进制数据,BLOB和TEXT用于大对象数据。3.排序规则如utf8mb4_unicode_ci忽略大小写,适合用户名;utf8mb4_bin区分大小写,适合需要精确比较的字段。

最佳的MySQLVARCHAR列长度选择应基于数据分析、考虑未来增长、评估性能影响及字符集需求。1)分析数据以确定典型长度;2)预留未来扩展空间;3)注意大长度对性能的影响;4)考虑字符集对存储的影响。通过这些步骤,可以优化数据库的效率和扩展性。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

安全考试浏览器
Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

Dreamweaver Mac版
视觉化网页开发工具

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

WebStorm Mac版
好用的JavaScript开发工具

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境