前面一篇文章已经分享了搭建Spring MVC:http://www.linuxidc.com/Linux/2015-02/113103.htm 这一篇来链接数据库PostgreSQL 1、在
前面一篇文章已经分享了搭建Spring MVC:
这一篇来链接数据库PostgreSQL
1、在pom.xml添加几个依赖
2、创建jdbc.properties配置文件
ticket.database.driver = org.postgresql.Driver
ticket.database.url = jdbc:postgresql://***.dev.cn6.qunar.com:5433/check_result
ticket.database.username = menpiao_dev
ticket.database.password = ***-***-***
3、在dispatcher-servlet.xml里添加数据源
4、创建测试Service类
package com.qunar.check.Service;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.sql.DataSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestService {
public void test() {
try {
ApplicationContext ctx = new ClassPathXmlApplicationContext("dispatcher-servlet.xml");
DataSource ds = ctx.getBean("dataSource", DataSource.class);
Connection conn = ds.getConnection();
Statement st = conn.createStatement();
ResultSet rt = st.executeQuery("select * from datasource");
while (rt.next()) {
String test1 = rt.getString(2);
System.out.println(test1);
}
rt.close();
st.close();
conn.close();
} catch (Exception e) {
System.out.println(e);
} finally {
}
}
public static void main(String args[]){
TestService t = new TestService();
t.test();
}
}
5、测试:
INFO: Pre-instantiating singletons in : defining beans [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,testController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.view.InternalResourceViewResolver#0,dataSource]; root of factory hierarchy
一月 27, 2015 11:46:43 下午 org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/index.do] onto handler [com.qunar.check.Controller.TestController@75be5b6]
test
下载地址:
------------------------------------------分割线------------------------------------------
免费下载地址在
用户名与密码都是
具体下载目录在 /2015年资料/2月/8日/Spring MVC 链接 PostgreSQL/
下载方法见
------------------------------------------分割线------------------------------------------
下面的文章您可能也喜欢
CentOS 6.3环境下yum安装PostgreSQL 9.3
PostgreSQL缓存详述
Windows平台编译 PostgreSQL
Ubuntu下LAPP(Linux+Apache+PostgreSQL+PHP)环境的配置与安装
Ubuntu上的phppgAdmin安装及配置
CentOS平台下安装PostgreSQL9.3
PostgreSQL配置Streaming Replication集群
如何在CentOS 7/6.5/6.4 下安装PostgreSQL 9.3 与 phpPgAdmin
------------------------------------------分割线------------------------------------------
PostgreSQL 的详细介绍:请点这里
PostgreSQL 的下载地址:请点这里
本文永久更新链接地址:
,
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)考虑字符集对存储的影响。通过这些步骤,可以优化数据库的效率和扩展性。

mysqlblobshavelimits:tinyblob(255bytes),blob(65,535 bytes),中间布洛布(16,777,215个比例),andlongblob(4,294,967,967,295 bytes).tousebl观察性:1)考虑performance impactsandSandStorelargeblobsextern; 2)管理backbackupsandreplication carecration; 3)usepathsinst

自动化在MySQL中创建用户的最佳工具和技术包括:1.MySQLWorkbench,适用于小型到中型环境,易于使用但资源消耗大;2.Ansible,适用于多服务器环境,简单但学习曲线陡峭;3.自定义Python脚本,灵活但需确保脚本安全性;4.Puppet和Chef,适用于大规模环境,复杂但可扩展。选择时需考虑规模、学习曲线和集成需求。

是的,YouCansearchInIdeAblobInMysqlusingsPecificteChniques.1)转换theblobtoautf-8StringWithConvertFunctionWithConvertFunctionandSearchusiseLike.2)forCompresseBlyblobs,useuncompresseblobs,useuncompressbeforeconversion.3)acpperformance impperformance imperformance imptactsanddataEccoding.4)


热AI工具

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

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

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

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

热门文章

热工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

SublimeText3 Linux新版
SublimeText3 Linux最新版

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

SublimeText3 英文版
推荐:为Win版本,支持代码提示!

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