Skip to content

Instantly share code, notes, and snippets.

View Krishanx92's full-sized avatar
🎯
Focusing

Krishanx92

🎯
Focusing
  • WSO2
  • SriLanka
  • 00:21 (UTC -12:00)
  • LinkedIn in/wkrishan
View GitHub Profile
package mvcproject;
import javax.swing.SwingUtilities;
public class Main {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
package mvcproject;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Controller {
private Model model;
private View view;
private ActionListener actionListener;
public class View {
private JFrame frame;
private JLabel label;
private JButton button;
public View(String text){
frame = new JFrame("View");
frame.getContentPane().setLayout(new BorderLayout());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
package mvcproject;
public class Model {
private int Apple;
public Model(){
Apple=0;
}
public Void getid(){
String result="";
InputStream isr=null;
JSONObject jObj = null;
try{
HttpClient httpClient=new DefaultHttpClient();
HttpPost httpPost=new HttpPost("http://10.0.2.2:8080/my%20project/first.php");
List<NameValuePair> nameValuePairs1 = new ArrayList<NameValuePair>(1);
TextView t;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
t=(TextView)findViewById(R.id.textView);
StrictMode.enableDefaults();
}
@Krishanx92
Krishanx92 / first.php
Last active September 10, 2015 02:04
<?php $conn=odbc_connect('firstsql','sa','krishan');
if (!$conn) { exit("Connection Failed: " . $conn); }
$rs=odbc_exec($conn,"SELECT name FROM Dept ");
if (!$rs) {exit("Error in SQL");}
//retreive data into array
$data = array();
$i=0;
while( $row = odbc_fetch_array($rs) ) {
$data[$i] = $row;
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, SQLException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
dbconn=new DatabaseConnection();
conn=dbconn.setConnection();
stmt=conn.createStatement();
query="select * from emp ;";
res =dbconn.getResult(query, conn);
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form action="InsertData" method="post">
<table>
<tr><td>UserName</td>