package threads;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import java.sql.*;
class server extends TimerTask {
public void ResultScheck_inact_auct(){
try
{
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/auktion", "root", "mksms");
;
Statement state = null;
state = con.createStatement();
ResultSet rs = null;
rs = state.executeQuery("SELECT * FROM auktion");
while(rs.next()){
System.out.println(rs.getString("start"));
}
}catch(SQLException e )
{System.out.println("SQL Error "+e)
;
}
}
public static void postMail( String recipient,
String subject,
String message, String from )
throws MessagingException
{
Properties props = new Properties();
props.put( "mailto.t-online.de", "m" );
Session session = Session.getDefaultInstance( props );
Message msg = new MimeMessage( session );
InternetAddress addressFrom = new InternetAddress( from );
msg.setFrom( addressFrom );
InternetAddress addressTo = new InternetAddress( recipient );
msg.setRecipient( Message.RecipientType.TO, addressTo );
msg.setSubject( subject );
msg.setContent( message, "text/plain" );
Transport.send( msg );
}
public void servers(){
}
public void run(){
try
{
Class.forName("com.mysql.jdbc.Driver");
}catch(ClassNotFoundException e )
{System.out.println("Hi "+e)
;
}
try
{
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/auktion", "root", "mksms");
;
Statement state = null;
state = con.createStatement();
ResultSet rs = null;
rs = state.executeQuery("SELECT * FROM auktion");
while(rs.next()){
mailfunc mal = new mailfunc();
try{
mal.postMail("mksms@t-online.de","mike","mike","venlox@t-online.de");
}catch(Exception e){ System.out.println("mksm"+e);}
System.out.println(rs.getString("start"));
}
}catch(SQLException e )
{System.out.println("SQL Error "+e)
;
}
System.out.println("Hallo Mike!");
}
}