晚上做数据库导入,早上看显示失败,是因为数据库关闭,在linux系统查看数据库确实关闭,查看alert日志,
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了晚上做数据库导入,早上看显示失败,是因为数据库关闭,在linux系统查看数据库确实关闭,查看alert日志,相关的知识,希望对你有一定的参考价值。
日志如下(基本和这个一样,就是数据文件名不一样):
KCF: write/open error block=0x3e0ac1 online=1
file=31 /cunchu/oradata/ts_fatslim_20.dbf
error=27072 txt: 'Linux-x86_64 Error: 5: Input/output error
Additional information: 4
Additional information: 4065985
Additional information: -1'
Errors in file /app/oracle/product/diag/rdbms/fatslim/fatslim/trace/fatslim_dbw0_6100.trc:
ORA-01242: data file suffered media failure: database in NOARCHIVELOG mode
ORA-01114: IO error writing block to file 31 (block # 4065985)
ORA-01110: data file 31: '/cunchu/oradata/ts_fatslim_20.dbf'
ORA-27072: File I/O error
Linux-x86_64 Error: 5: Input/output error
Additional information: 4
Additional information: 4065985
Additional information: -1
DBW0 (ospid: 6100): terminating the instance due to error 1242
Thu Dec 23 11:51:10 2010
Error occured while spawning process m000; error = 1242
Instance terminated by DBW0, pid = 6100
Fri Dec 24 15:36:33 2010
请求大神什么原因?
ps aux |grep mysqld
/etc/init.d/mysqld status;
查看具体的详细参数
mysql -uroot -p -e "show status\G;"
在java中显示基于时间的早晨,下午,晚上,晚上的消息
我想做什么::
显示基于的消息
- 早上好(上午12点至下午12点)
- 中午后(中午12点至下午4点)好
- 晚上好(下午4点到晚上9点)
- 晚安(晚上9点至早上6点)
码::
我使用24小时格式来获得这种逻辑
private void getTimeFromAndroid() {
Date dt = new Date();
int hours = dt.getHours();
int min = dt.getMinutes();
if(hours>=1 || hours<=12){
Toast.makeText(this, "Good Morning", Toast.LENGTH_SHORT).show();
}else if(hours>=12 || hours<=16){
Toast.makeText(this, "Good Afternoon", Toast.LENGTH_SHORT).show();
}else if(hours>=16 || hours<=21){
Toast.makeText(this, "Good Evening", Toast.LENGTH_SHORT).show();
}else if(hours>=21 || hours<=24){
Toast.makeText(this, "Good Night", Toast.LENGTH_SHORT).show();
}
}
题:
- 这是最好的方式,如果没有这是最好的方式
你应该做的事情如下:
Calendar c = Calendar.getInstance();
int timeOfDay = c.get(Calendar.HOUR_OF_DAY);
if(timeOfDay >= 0 && timeOfDay < 12){
Toast.makeText(this, "Good Morning", Toast.LENGTH_SHORT).show();
}else if(timeOfDay >= 12 && timeOfDay < 16){
Toast.makeText(this, "Good Afternoon", Toast.LENGTH_SHORT).show();
}else if(timeOfDay >= 16 && timeOfDay < 21){
Toast.makeText(this, "Good Evening", Toast.LENGTH_SHORT).show();
}else if(timeOfDay >= 21 && timeOfDay < 24){
Toast.makeText(this, "Good Night", Toast.LENGTH_SHORT).show();
}
如果有人对Dart和Flutter看起来相同:没有if语句的代码 - 易于阅读和编辑。
main() {
int hourValue = DateTime.now().hour;
print(checkDayPeriod(hourValue));
}
String checkDayPeriod(int hour) {
int _res = 21;
Map<int, String> dayPeriods = {
0: 'Good night',
12: 'Good morning',
16: 'Good afternoon',
21: 'Good evening',
};
dayPeriods.forEach(
(key, value) {
if (hour < key && key <= _res) _res = key;
},
);
return dayPeriods[_res];
}
我会将你的if/elseif
声明缩短为:
String greeting = null;
if(hours>=1 && hours<=12){
greeting = "Good Morning";
} else if(hours>=12 && hours<=16){
greeting = "Good Afternoon";
} else if(hours>=16 && hours<=21){
greeting = "Good Evening";
} else if(hours>=21 && hours<=24){
greeting = "Good Night";
}
Toast.makeText(this, greeting, Toast.LENGTH_SHORT).show();
对于正在为@SMA的答案寻找最新Kotlin语法的人来说,这里是辅助函数:
fun getGreetingMessage():String{
val c = Calendar.getInstance()
val timeOfDay = c.get(Calendar.HOUR_OF_DAY)
return when (timeOfDay) {
in 0..11 -> "Good Morning"
in 12..15 -> "Good Afternoon"
in 16..20 -> "Good Evening"
in 21..23 -> "Good Night"
else -> {
"Hello"
}
}
}
java.time
我建议使用Java 8 LocalTime。
也许创建一个这样的类来处理你的时间问题。
public class GreetingMaker { // think of a better name than this.
private static final LocalTime MORNING = LocalTime.of(0, 0, 0);
private static final LocalTime AFTER_NOON = LocalTime.of(12, 0, 0);
private static final LocalTime EVENING = LocalTime.of(16, 0, 0);
private static final LocalTime NIGHT = LocalTime.of(21, 0, 0);
private LocalTime now;
public GreetingMaker(LocalTime now) {
this.now = now;
}
public void printTimeOfDay() { // or return String in your case
if (between(MORNING, AFTER_NOON)) {
System.out.println("Good Morning");
} else if (between(AFTER_NOON, EVENING)) {
System.out.println("Good Afternoon");
} else if (between(EVENING, NIGHT)) {
System.out.println("Good Evening");
} else {
System.out.println("Good Night");
}
}
private boolean between(LocalTime start, LocalTime end) {
return (!now.isBefore(start)) && now.isBefore(end);
}
}
您确定它是否在第一个间隔中,然后所有其他间隔取决于上限。所以你可以做得更短:
String greeting = null;
if(hours>=1 && hours<=11){
greeting = "Good Morning";
} else if(hours<=15){
greeting = "Good Afternoon";
} else if(hours<=20){
greeting = "Good Evening";
} else if(hours<=24){
greeting = "Good Night";
}
Toast.makeText(this, greeting, Toast.LENGTH_SHORT).show();
试试这段代码(不推荐使用Date类和获取Date类中的分钟方法。)
private void getTimeFromAndroid() {
Date dt = new Date();
Calendar c = Calendar.getInstance();
c.setTime(dt);
int hours = c.get(Calendar.HOUR_OF_DAY);
int min = c.get(Calendar.MINUTE);
if(hours>=1 && hours<=12){
Toast.makeText(this, "Good Morning", Toast.LENGTH_SHORT).show();
}else if(hours>=12 && hours<=16){
Toast.makeText(this, "Good Afternoon", Toast.LENGTH_SHORT).show();
}else if(hours>=16 && hours<=21){
Toast.makeText(this, "Good Evening", Toast.LENGTH_SHORT).show();
}else if(hours>=21 && hours<=24){
Toast.makeText(this, "Good Night", Toast.LENGTH_SHORT).show();
}
}
使用Time4J(或Android上的Time4A)可以使用以下不需要任何if-else语句的解决方案:
ChronoFormatter<PlainTime> parser =
ChronoFormatter.ofTimePattern("hh:mm a", PatternType.CLDR, Locale.ENGLISH);
PlainTime time = parser.parse("10:05 AM");
Map<PlainTime, String> table = new HashMap<>();
table.put(PlainTime.of(1), "Good Morning");
table.put(PlainTime.of(12), "Good Afternoon");
table.put(PlainTime.of(16), "Good Evening");
table.put(PlainTime.of(21), "Good Night");
ChronoFormatter<PlainTime> customPrinter=
ChronoFormatter
.setUp(PlainTime.axis(), Locale.ENGLISH)
.addDayPeriod(table)
.build();
System.out.println(customPrinter.format(time)); // Good Morning
还有另一种基于模式的方法让区域设置基于CLDR数据以标准方式决定如何格式化时钟时间:
ChronoFormatter<PlainTime> parser =
ChronoFormatter.ofTimePattern("hh:mm a", PatternType.CLDR, Locale.ENGLISH);
PlainTime time = parser.parse("10:05 AM");
ChronoFormatter<PlainTime> printer1 =
ChronoFormatter.ofTimePattern("hh:mm B", PatternType.CLDR, Locale.ENGLISH);
System.out.println(printer1.format(time)); // 10:05 in the morning
ChronoFormatter<PlainTime> printer2 =
ChronoFormatter.ofTimePattern("B", PatternType.CLDR, Locale.ENGLISH)
.with(Attributes.OUTPUT_CONTEXT, OutputContext.STANDALONE);
System.out.println(printer2.format(time)); // morning
我所知道的唯一一个也可以做到这一点的其他库(但是以一种尴尬的方式)是ICU4J。
private String getStringFromMilli(long millis) {
Calendar c = Calendar.getInstance();
c.setTimeInMillis(millis);
int hours = c.get(Calendar.HOUR_OF_DAY);
if(hours >= 1 && hours <= 12){
return "MORNING";
}else if(hours >= 12 && hours <= 16){
return "AFTERNOON";
}else if(hours >= 16 && hours <= 21){
return "EVENING";
}else if(hours >= 21 && hours <= 24){
return "NIGHT";
}
return null;
}
当我写作
Calendar c = Calendar.getInstance();
int timeOfDay = c.get(Calendar.HOUR_OF_DAY);
我没有得到输出,也没有显示任何错误。只是timeOfDay
不会在代码中分配任何值。我觉得这是因为在执行Calendar.getInstance()
时有些线程。但当我折断线条时,它对我有用。请参阅以下代码:
int timeOfDay = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
if(timeOfDay >= 0 && timeOfDay < 12){
greeting.setText("Good Morning");
}else if(timeOfDay >= 12 && timeOfDay < 16){
greeting.setText("Good Afternoon");
}else if(timeOfDay >= 16 && timeOfDay < 21){
greeting.setText("Good Evening");
}else if(timeOfDay >= 21 && timeOfDay < 24){
greeting.setText("Good Morning");
}
以上是关于晚上做数据库导入,早上看显示失败,是因为数据库关闭,在linux系统查看数据库确实关闭,查看alert日志,的主要内容,如果未能解决你的问题,请参考以下文章