I lost root’s password, again.
we need to stop mysql and start it in safe mode. I tried many ways to kill mysql, but only this works for my Ubuntu 14.04:
root@myhost:/usr/bin# initctl --system stop mysql
sudo mysqld_safe --skip-grant-tables &
mysql -uroot
use mysql;
update user set password=PASSWORD("new_password") where User='root';
flush privileges;
quit
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
you may try to login using the new password now:
mysql -u root -p
if you’re using a password file, remember to update it.
[client] user=root password=new_password
useful links
http://stackoverflow.com/questions/18733944/ubuntu-cant-stop-mysqld
https://www.digitalocean.com/community/questions/setup-mysql-on-ubuntu-droplet-getting-error-error-1045-28000-access-denied-for-user-root-localhost-using-password-yes
SELECT (CONVERT(NUMERIC(20, 0), '100') + 1)
>> 101
SELECT (CONVERT(VARCHAR(3), 100) + 'ABC')
>> 100ABC
List all collections:
<collections>{
for $collection in cts:collections()
return <collection> { $collection } </collection>
}</collections>
Select latest record from collection:
let $uris := cts:uris( (), (), cts:properties-query( cts:and-query(( cts:collection-query('/collections/coll-A'), cts:collection-query('latest') )) ) )
return doc($uris)
Sybase doesn’t have this feature, however we can use lift/right join + union to get it:
SELECT * FROM A LEFT OUTER JOIN B ON…
UNION
SELECT * FROM A RIGHT OUTER JOIN B ON…
UNIN will remove the duplicated records.
Set up Maven dependences
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.10.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.10.2.0</version>
</dependency>
Connect to the DB using JDBC
This method will print out all Tables; // before you do anything with the Database, there should be some System tables already.
package com.liguoliang;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class JDBCTest {
private static final String DB_URL = "jdbc:derby:tempDBForTest;create=true";
public static void main(String[] args) {
Connection conn = null ;
try {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver") ;
conn = DriverManager.getConnection(DB_URL);
String sql = "SELECT TABLENAME FROM SYS.SYSTABLES";
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
System.out.println("Rs: " + rs.getString(1));
}
} catch (SQLException se) {
se.printStackTrace();
} catch(ClassNotFoundException e){
System.out.println("JDBC Driver not found in CLASSPATH") ;
}finally {
if(conn != null){
try{
conn.close() ;
} catch(SQLException se){
se.printStackTrace();
}
}
}
}
}
Use Eclipse to manage your Derby
Switch to ‘Database Development’ perspective, you may create/manage Derby DB/table.
// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.