行得太快,記得太少 Living in IT…

15十二/110

Unix Domain套接字的Java包 junixsocket

junixsocket 是一个通过 Java JNI (Java本地接口)实现的基于 Unix Domain 套接字(AF_UNIX )进行通讯的 Java 开发包。

junixsocket 扩展了 Java 的 Socket API ,支持基于 AF_UNIX 的 RMI 通讯,还可以使用 Unix Domain 套接字直接连接本地的 MySQL 服务器。

下面是一段使用 junixsocket 连接 MySQL 的代码示例:

import org.newsclub.net.mysql.AFUNIXDatabaseSocketFactory;

Class.forName("com.mysql.jdbc.Driver").newInstance();

Properties props = new Properties();
props.put("user", "test");
props.put("password", "test");
props.put("socketFactory", AFUNIXDatabaseSocketFactory.class.getName());
props.put("junixsocket.file", "/tmp/mysql.sock");

Connection conn = DriverManager.getConnection("jdbc:mysql:///库名", props);

 

需要在/opt/newsclub/lib-native 目录下添加

libjunixsocket-linux-1.5-amd64.so
libjunixsocket-linux-1.5-i386.so
libjunixsocket-macosx-1.5-i386.dylib
libjunixsocket-macosx-1.5-x86_64.dylib

 

以上四个文件可以在以下压缩包中获取到,目录在 junixsocket-1.3\lib-native

需要JAR包,可通过下面链接下载

http://junixsocket.googlecode.com/files/junixsocket-1.3-bin.tar.bz2

分类: JAVA 没有评论
25十/110

MyEclipse6.6安装SVN

http://subclipse.tigris.org/update_1.6.x

分类: JAVA 没有评论
17三/110

MyEclipse Blue Edition 注册程序

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Crack {
 public static final void main(String[] args) {
  String id = "用户名随意填";
  String num = "999";
  System.out.println(getSerial(id, "100", num, false));
 }

 public static String getSerial(String userId, String version,
   String licenseNum, boolean selected) {
  Calendar cal = Calendar.getInstance();
  cal.add(1, 3);
  cal.add(6, -1);
  NumberFormat nf = new DecimalFormat("000");
  licenseNum = nf.format(Integer.valueOf(licenseNum));
  String verTime = selected ? (new StringBuffer("-")).append(
    (new SimpleDateFormat("yyMMdd")).format(cal.getTime())).append(
    "0").toString() : "-1212310";
  String type = "YE3MB-";
  String need = (new StringBuffer(String.valueOf(userId.substring(0, 1))))
    .append(type).append(version).append(licenseNum)
    .append(verTime).toString();
  String dx = (new StringBuffer(String.valueOf(need)))
    .append(
      "Decompiling this copyrighted software is a violation of both your license agreement and the Digital Millenium Copyright Act of 1998 (http://www.loc.gov/copyright/legislation/dmca.pdf). Under section 1204 of the DMCA, penalties range up to a $500,000 fine or up to five years imprisonment for a first offense. Think about it; pay for a license, avoid prosecution, and feel better about yourself.")

    .append(userId).toString();
  int suf = decode(dx);
  String code = (new StringBuffer(String.valueOf(need))).append(
    String.valueOf(suf)).toString();
  return change(code);
 }

 private static int decode(String s) {
  int i = 0;
  char ac[] = s.toCharArray();
  int j = 0;
  for (int k = ac.length; j < k; j++)
   i = 31 * i + ac[j];

  return Math.abs(i);
 }

 private static String change(String s) {
  byte abyte0[] = s.getBytes();
  char ac[] = new char[s.length()];
  int i = 0;
  for (int k = abyte0.length; i < k; i++) {
   int j = abyte0[i];
   if (j >= 48 && j <= 57)
    j = ((j - 48) + 5) % 10 + 48;
   else if (j >= 65 && j <= 90)
    j = ((j - 65) + 13) % 26 + 65;
   else if (j >= 97 && j <= 122)
    j = ((j - 97) + 13) % 26 + 97;
   ac[i] = (char) j;
  }

  return String.valueOf(ac);
 }
}

分类: JAVA 没有评论
25十/100

JAVA中“.”转义问题引起的异常

在用"."截取ip时,用到String[] ipArray = ip.split(".");

报 java.lang.ArrayIndexOutOfBoundsException异常,google了下,原来java中“.”需要转移才可。

换用

String[] ipArray = ip.split("\\.");

成功!

分类: JAVA 没有评论